Anope IRC Services  Version 2.0
Public Member Functions | Data Fields | Protected Attributes
Socket Class Reference

#include <sockets.h>

Inheritance diagram for Socket:
Inheritance graph
[legend]
Collaboration diagram for Socket:
Collaboration graph
[legend]

Public Member Functions

 Socket ()
 
 Socket (int sock, bool ipv6=false, int type=SOCK_STREAM)
 
virtual ~Socket ()
 
int GetFD () const
 
bool IsIPv6 () const
 
bool SetBlocking (bool state)
 
void Bind (const Anope::string &ip, int port=0)
 
virtual bool Process ()
 
virtual bool ProcessRead ()
 
virtual bool ProcessWrite ()
 
virtual void ProcessError ()
 

Data Fields

std::bitset< SF_SIZEflags
 
sockaddrs bindaddr
 
SocketIOio
 

Protected Attributes

int sock
 
bool ipv6
 

Detailed Description

Definition at line 194 of file sockets.h.

Constructor & Destructor Documentation

Socket::Socket ( )

Empty constructor, should not be called.

Definition at line 447 of file sockets.cpp.

Socket::Socket ( int  sock,
bool  ipv6 = false,
int  type = SOCK_STREAM 
)

Constructor, possibly creates the socket and adds it to the engine

Parameters
sockThe socket to use, -1 if we need to create our own
ipv6true if using ipv6
typeThe socket type, defaults to SOCK_STREAM

Definition at line 452 of file sockets.cpp.

References SocketEngine::Change(), NormalSocketIO, SF_READABLE, and SocketEngine::Sockets.

Socket::~Socket ( )
virtual

Destructor, closes the socket and removes it from the engine

Definition at line 465 of file sockets.cpp.

References anope_close, SocketEngine::Change(), SF_READABLE, SF_WRITABLE, and SocketEngine::Sockets.

Member Function Documentation

void Socket::Bind ( const Anope::string ip,
int  port = 0 
)

Bind the socket to an ip and port

Parameters
ipThe ip
portThe port

Definition at line 493 of file sockets.cpp.

Referenced by Uplink::Connect(), and MyManager::SetIPPort().

int Socket::GetFD ( ) const
bool Socket::IsIPv6 ( ) const

Check if this socket is IPv6

Returns
true or false

Definition at line 479 of file sockets.cpp.

Referenced by SocketIO::Bind(), SSLSocketIO::Connect(), and SocketIO::Connect().

bool Socket::Process ( )
virtual

Called when there either is a read or write event.

Returns
true to continue to call ProcessRead/ProcessWrite, false to not continue

Reimplemented in ClientSocket, and ConnectionSocket.

Definition at line 498 of file sockets.cpp.

Referenced by SocketEngine::Process().

void Socket::ProcessError ( )
virtual

Called when there is an error for this socket

Returns
true on success, false to drop this socket

Reimplemented in ClientSocket, and ConnectionSocket.

Definition at line 513 of file sockets.cpp.

Referenced by SocketEngine::Process().

bool Socket::ProcessRead ( )
virtual

Called when there is something to be received for this socket

Returns
true on success, false to drop this socket

Reimplemented in UDPSocket, TCPSocket::Client, Pipe, ListenSocket, BinarySocket, BufferedSocket, HTTPProxyConnect, and UplinkSocket.

Definition at line 503 of file sockets.cpp.

Referenced by SocketEngine::Process().

bool Socket::ProcessWrite ( )
virtual

Called when the socket is ready to be written to

Returns
true on success, false to drop this socket

Reimplemented in NotifySocket, UDPSocket, TCPSocket::Client, BinarySocket, BufferedSocket, MyHTTPClient, and ProxyCallbackListener::ProxyCallbackClient.

Definition at line 508 of file sockets.cpp.

Referenced by SocketEngine::Process().

bool Socket::SetBlocking ( bool  state)

Mark a socket as (non)blocking

Parameters
statetrue to enable blocking, false to disable blocking
Returns
true if the socket is now blocking

Definition at line 484 of file sockets.cpp.

References F_GETFL, F_SETFL, fcntl(), and O_NONBLOCK.

Referenced by MyRedisService::BlockAndProcess().

Field Documentation

sockaddrs Socket::bindaddr

Definition at line 206 of file sockets.h.

Referenced by SocketIO::Bind().

std::bitset<SF_SIZE> Socket::flags
SocketIO* Socket::io
bool Socket::ipv6
protected

Definition at line 200 of file sockets.h.

int Socket::sock
protected

Definition at line 198 of file sockets.h.

Referenced by Pipe::Pipe().


The documentation for this class was generated from the following files: