Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

RNReplicaNet::XPSocket Class Reference

#include <XPSocketClass.h>

Inheritance diagram for RNReplicaNet::XPSocket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 XPSocket ()
virtual ~XPSocket ()
virtual int Create (void)
int Connect (const XPAddress &addr)
int Send (const char *data)
int Send (const char *data, const int len)
int Recv (char *const data, const int maxlen)
int Close (void)
int Listen (const int port=XPSOCK_PORT_ANY)
XPSocketAccept (void)
int SetSendBuffer (const int size)
int SetRecvBuffer (const int size)
int GetAddress (XPAddress *const addr)
int GetPeerAddress (XPAddress *const addr)
int MutateSocket (XPSocket *socket)
bool IsAlive (void)
t_XPSocket * GetSocketPointer (void)

Static Public Member Functions

static int GetLastError (void)
static int GetMaxPacketSize (void)

Friends

class XPSocketUrgent

Detailed Description

This class is a socket which is a potential connection of actualy connection to a machine somewhere else in the world. This uses the underlying XPSocket library which in turn uses the winsock or berkley sockets API. Most member functions return an XPSOCK_EERROR code. XPSOCK_EOK indicates no error. XPSOCK_EWOULDBLOCK is a non-fatal error and means the socket operation would have blocked the current thread at this point. If XPSOCK_EERROR is returned the user should use XPSocket::GetLastError() to find out the actual error code


Constructor & Destructor Documentation

XPSocket::XPSocket  ) 
 

The ctor for an XPSocket This checks to make sure sockets are active and sets some initial states. At this point no connection is made for the socket

XPSocket::~XPSocket  )  [virtual]
 

The dtor for an XPSocket This cleans up everything for this socket


Member Function Documentation

XPSocket * XPSocket::Accept void   ) 
 

Accepts any pending connections for this socket. This should be used with the Listen() member function

Returns:
returns NULL if no connection was pending or returns the pointer to the new connected XPSocket or pcXPSOCK_EERROR if an error occured

Reimplemented in RNReplicaNet::XPStream.

int XPSocket::Close void   ) 
 

Closes the socket but does not delete the memory for the XPSocket class

Returns:
returns an XPSOCK_EERROR code.

Reimplemented in RNReplicaNet::XPStream.

int XPSocket::Connect const XPAddress addr  ) 
 

Tries to connect this socket to a network address

Parameters:
addr the address to try to connect to
Returns:
returns an XPSOCK_EERROR code.

int XPSocket::Create void   )  [virtual]
 

Creates a TCP style socket. This is the first stage to creating a connection

Returns:
returns an XPSOCK_EERROR code.

Reimplemented in RNReplicaNet::XPStream.

int XPSocket::GetAddress XPAddress *const   addr  ) 
 

Fills in the internet address and port of the socket to the address structure.

Parameters:
addr the address structure to fill in
Returns:
returns XPSOCK_EOK or an XPSOCK_EERROR error code.

int XPSocket::GetLastError void   )  [static]
 

Gets the last error reported by the XPSocket API

Returns:
returns an XPSOCK_EERROR code.

static int RNReplicaNet::XPSocket::GetMaxPacketSize void   )  [inline, static]
 

Returns the maximum size for a packet

Returns:
the maximum size for a data packet for this socket

Reimplemented in RNReplicaNet::XPSocketUrgent, and RNReplicaNet::XPStream.

int XPSocket::GetPeerAddress XPAddress *const   addr  ) 
 

Fills in the internet address of the peer of the socket to the address structure.

Parameters:
addr the address structure to fill in
Returns:
returns XPSOCK_EOK or an XPSOCK_EERROR error code.

t_XPSocket * XPSocket::GetSocketPointer void   ) 
 

Access for the t_XPSocket pointer

Returns:
The t_XPSocket pointer associated with this class

bool XPSocket::IsAlive void   ) 
 

Tests the alive state of the socket

Returns:
returns true if the socket is alive or false if the socket is dead

int XPSocket::Listen const int  port = XPSOCK_PORT_ANY  ) 
 

Makes the socket listen on a certain port number

Parameters:
port the port number to listen on for incoming connections
Returns:
returns an XPSOCK_EERROR code.

int XPSocket::MutateSocket XPSocket socket  ) 
 

Mutates this socket class to use a socket

Parameters:
socket the socket to mutate to
Returns:
returns XPSOCK_EOK or an XPSOCK_EERROR error code.

int XPSocket::Recv char *const   data,
const int  maxlen
 

Tries to receive data that is waiting for this socket

Parameters:
data the pointer to the buffer to receive the data
maxlen the maximum length of the data buffer
Returns:
returns the length of the data received or 0 for no data pending or an XPSOCK_EERROR code.

Reimplemented in RNReplicaNet::XPStream.

int XPSocket::Send const char *  data,
const int  len
 

Sends data to the peer (the connected machine) for this socket

Parameters:
data the pointer to the data to send
len the length of the data to send
Returns:
returns an XPSOCK_EERROR code.

Reimplemented in RNReplicaNet::XPStream.

int XPSocket::Send const char *  data  ) 
 

Sends a NULL terminated string to the peer (the connected machine) for this socket

Parameters:
data The pointer to the NULL terminated string
Returns:
returns an XPSOCK_EERROR code.

int XPSocket::SetRecvBuffer const int  size  ) 
 

Sets the size of the recv buffer for the socket

Parameters:
size The size to set the recv buffer to or -1 to only return the value
Returns:
the new size of the recv buffer

int XPSocket::SetSendBuffer const int  size  ) 
 

Sets the size of the send buffer for the socket

Parameters:
size The size to set the send buffer to or -1 to only return the value
Returns:
the new size of the send buffer


The documentation for this class was generated from the following files:
Generated on Sun Oct 30 01:12:23 2005 for XPSockets by  doxygen 1.4.1