ccuty  1.0
 All Classes Namespaces Files Functions Enumerations Macros Pages
Public Member Functions | List of all members
ccuty::ServerSocket Class Reference

TCP/IP server socket. More...

Public Member Functions

 ServerSocket ()
 Creates a new server socket. More...
 
virtual Socketaccept ()
 Accepts a new connection request and returns the corresponding socket. More...
 
virtual int bind (int port, int backlog=50)
 Assigns the socket to the local address. More...
 
virtual int close ()
 Closes the socket.
 
bool isClosed () const
 Returns true if the socket has been closed.
 
int descriptor ()
 Returns the Unix descriptor of the socket.
 
int setReceiveBufferSize (int size)
 Sets the SO_RCVBUF option to the specified value.
 
int setReuseAddress (bool)
 Enables/disables the SO_REUSEADDR socket option.
 
int setSoTimeout (int timeout)
 Enables/disables SO_TIMEOUT with the specified timeout (in milliseconds).
 
int setTcpNoDelay (bool)
 Turns on/off TCP coalescence (useful in some cases to avoid delays).
 

Detailed Description

TCP/IP server socket.

This class implements a TCP/IP socket that waits for requests to come in over the network. AF_INET connections following the IPv4 Internet protocol are supported.

Note
TCP/IP sockets do not preserve record boundaries but SocketBuffer solves this problem.

Constructor & Destructor Documentation

ccuty::ServerSocket::ServerSocket ( )

Creates a new server socket.

Creates a listening socket that waits for connection requests by TCP/IP clients.

Member Function Documentation

Socket * ccuty::ServerSocket::accept ( )
virtual

Accepts a new connection request and returns the corresponding socket.

By default, this function blocks the caller until a connection is present.

Returns
the new Socket or nullptr on error.
int ccuty::ServerSocket::bind ( int  port,
int  backlog = 50 
)
virtual

Assigns the socket to the local address.

The socket must be bound before using it.

Returns
0 on success or a negative value on error which is one of Socket::Errors

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