TCPSocket Class Reference

TCP/IP socket class. More...

#include <tcpsocket.h>

Inheritance diagram for TCPSocket:

CoreSocket

List of all members.

Public Member Functions

 TCPSocket ()
 The default constructor.
 TCPSocket (socket_t _socket)
 The constructor for existing sockets.
 ~TCPSocket ()
 The destructor.
int Accept (TCPSocket **_socket)
 Accepts an incoming connection. Only good when listening for a connection.
int Connect (const char *_address, unsigned short _port)
 Establishes an outbound connection to the specified address and port.
int Listen (unsigned short _port)
 Listens for connections on the specified port.
socketState State () const
 Fetch the state of the socket.

Private Member Functions

int SetAttributes (socket_t _socket)
 Sets some important attributes on the socket.


Detailed Description

TCP/IP socket class.

Used for two-way TCP/IP communication.


Member Function Documentation

int Accept ( TCPSocket **  _socket  ) 

Accepts an incoming connection. Only good when listening for a connection.

Parameters:
_socket A pointer to a NULL TCPSocket pointer variable. (e.g. TCPSocket *blah = NULL; socket->Accept ( &blah ); )
Returns:
A pointer to a newly created TCPSocket instance for the new connection. If no incoming connections are pending, this returns NULL.

int Connect ( const char *  _address,
unsigned short  _port 
)

Establishes an outbound connection to the specified address and port.

Parameters:
_address The remote address to connect to. Can be a hostname, as it will be resolved by gethostbyname().
_port The remote port to connect to.

int Listen ( unsigned short  _port  )  [virtual]

Listens for connections on the specified port.

You need to Accept() connections after calling this.

Parameters:
_port The local port to listen on.

Implements CoreSocket.

int SetAttributes ( socket_t  _socket  )  [private, virtual]

Sets some important attributes on the socket.

Will set SO_LINGER and TCP_NODELAY on TCP sockets.

Parameters:
_socket The socket to modify.
Returns:
CC_ERR_NONE if no error is encountered, otherwise returns 'errno'.

Implements CoreSocket.

socketState State (  )  const [virtual]

Fetch the state of the socket.

Returns:
The current state of m_sock.
See also:
CrissCross::Network::socketState

Reimplemented from CoreSocket.


Generated on Sun Feb 8 11:10:00 2009 for CrissCross by  doxygen 1.5.8