Public Member Functions | Data Fields | Protected Attributes

Socket Class Reference

#include <sockets.h>

Inherited by BinarySocket [virtual], BufferedSocket [virtual], ClientSocket [virtual], ConnectionSocket [virtual], DNS::ReplySocket [virtual], ListenSocket [virtual], and Pipe.

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_SIZE > flags
sockaddrs bindaddr
SocketIOio

Protected Attributes

int sock
bool ipv6

Detailed Description

Definition at line 189 of file sockets.h.


Constructor & Destructor Documentation

Socket::Socket (  ) 

Empty constructor, should not be called.

Definition at line 416 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:
sock The socket to use, -1 if we need to create our own
ipv6 true if using ipv6
type The socket type, defaults to SOCK_STREAM

Definition at line 421 of file sockets.cpp.

References SocketEngine::Change(), io, ipv6, SetBlocking(), SF_READABLE, sock, and SocketEngine::Sockets.

Socket::~Socket (  )  [virtual]

Destructor, closes the socket and removes it from the engine

Definition at line 434 of file sockets.cpp.

References anope_close, SocketEngine::Change(), SocketIO::Destroy(), io, SF_READABLE, SF_WRITABLE, sock, 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:
ip The ip
port The port

Definition at line 462 of file sockets.cpp.

References SocketIO::Bind(), and io.

Referenced by Uplink::Connect().

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

Check if this socket is IPv6

Returns:
true or false

Definition at line 448 of file sockets.cpp.

References ipv6.

Referenced by SocketIO::Bind(), SocketIO::Connect(), and SSLSocketIO::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 ConnectionSocket, and ClientSocket.

Definition at line 467 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 ConnectionSocket, and ClientSocket.

Definition at line 482 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 BufferedSocket, BinarySocket, ListenSocket, Pipe, UplinkSocket, TCPSocket::Client, UDPSocket, and HTTPProxyConnect.

Definition at line 472 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 BufferedSocket, BinarySocket, TCPSocket::Client, UDPSocket, and ProxyCallbackListener::ProxyCallbackClient.

Definition at line 477 of file sockets.cpp.

Referenced by SocketEngine::Process().

bool Socket::SetBlocking ( bool  state  ) 

Mark a socket as (non)blocking

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

Definition at line 453 of file sockets.cpp.

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

Referenced by ListenSocket::ListenSocket(), and Socket().


Field Documentation

Definition at line 201 of file sockets.h.

Referenced by SocketIO::Bind(), and ListenSocket::ListenSocket().

std::bitset<SF_SIZE> Socket::flags
bool Socket::ipv6 [protected]

Definition at line 195 of file sockets.h.

Referenced by IsIPv6(), and Socket().

int Socket::sock [protected]

Definition at line 193 of file sockets.h.

Referenced by GetFD(), ListenSocket::ListenSocket(), Pipe::Pipe(), Socket(), and ~Socket().


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