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

CP_Socket Class Reference

Class to allow communication via sockets.

Inheritance diagram for CP_Socket:

CP_ServerSocket List of all members.

Getters

UInt32 GetAddress () const
CP_NetworkAddress GetNetworkAddress () const
UInt32 GetPeerAddress () const
CP_NetworkAddress GetPeerNetworkAddress () const
UInt16 GetPort () const
UInt16 GetPeerPort () const
CP_String GetHostName ()
static UInt32 GetHostByName (const CP_String &inHostName)
static CP_NetworkAddress GetHostAddressByName (const CP_String &inHostName)

Public Member Functions

Constructor / Destructor
 CP_Socket ()
 Constructor.
 CP_Socket (UInt32 inAddress, UInt16 inPort)
 CP_Socket (const char *inAddress, UInt16 inPort)
 CP_Socket (const CP_NetworkAddress &inAddress, UInt16 inPort)
virtual ~CP_Socket () throw ()
 Destructor.
Constructor / Destructor
 CP_Socket (int socketDescriptor)
 Constructor.
Constructor / Destructor
 CP_Socket (SOCKET socketDescriptor)
 Constructor.
Constructor / Destructor
 CP_Socket (int socketDescriptor)
 Constructor.

Protected Member Functions

void Initialize (void)
void GetConnectedSocketInfo (void)

Protected Attributes

CP_String fHostName
char fIsConnected
sockaddr_in fSocketAddress
hostentfnlp_host
int fSocketDescriptor
SOCKET fSocketDescriptor
CP_NetworkAddress fConnectedSocketAddress
UInt16 fConnectedSocketPort
CP_NetworkAddress fConnectedPeerAddress
UInt16 fConnectedPeerPort

Constructor & Destructor Documentation

CP_Socket::CP_Socket  ) 
 

Constructor.

Exceptions:
OSError exceptions.

CP_Socket::CP_Socket UInt32  inAddress,
UInt16  inPort
 

Constructor.

Parameters:
inAddress Address to connect to.
inPort Port to connect to.
Exceptions:
OSError exceptions.

CP_Socket::CP_Socket const char *  inAddress,
UInt16  inPort
 

Constructor.

Parameters:
inAddress Address to connect to.
inPort Port to connect to.
Exceptions:
OSError exceptions.

CP_Socket::CP_Socket const CP_NetworkAddress inAddress,
UInt16  inPort
 

Constructor.

Parameters:
inAddress Address to connect to.
inPort Port to connect to.
Exceptions:
OSError exceptions.

CP_Socket::~CP_Socket  )  throw () [virtual]
 

Destructor.

Exceptions:
OSError exceptions.

CP_Socket::CP_Socket int  socketDescriptor  ) 
 

Constructor.

Parameters:
socketDescriptor Existing socket descriptor to use with this class.
Exceptions:
none 

CP_Socket::CP_Socket SOCKET  socketDescriptor  ) 
 

CP_Socket::CP_Socket int  socketDescriptor  ) 
 


Member Function Documentation

void CP_Socket::Connect UInt32  inTimeoutInSeconds = 0  ) 
 

Establish a connection with the host.

Parameters:
inTimeoutInSeconds the timeout in seconds for the connect. If timeout is 0 then now timeout will happen
Exceptions:
OSError exceptions.
Returns:
void
Todo:
check if this is OK could be in milli seconds

void CP_Socket::Connect UInt32  inAddress,
UInt16  inPort,
UInt32  inTimeoutInSeconds = 0
 

Establish a connection with the host.

Parameters:
inAddress The address of the host to connect to.
inPort The port to connect to.
inTimeoutInSeconds the timeout in seconds for the connect. If timeout is 0 then now timeout will happen
Exceptions:
OSError exceptions.
Returns:
void

void CP_Socket::Connect const char *  inAddress,
UInt16  inPort,
UInt32  inTimeoutInSeconds = 0
 

Establish a connection with the host.

Parameters:
inAddress The address of the host to connect to.
inPort The port to connect to.
inTimeoutInSeconds the timeout in seconds for the connect. If timeout is 0 then now timeout will happen
Exceptions:
OSError exceptions.
Returns:
void

void CP_Socket::Connect const CP_NetworkAddress inAddress,
UInt16  inPort,
UInt32  inTimeoutInSeconds = 0
 

Establish a connection with the host.

Parameters:
inAddress The address of the host to connect to.
inPort The port to connect to.
inTimeoutInSeconds the timeout in seconds for the connect. If timeout is 0 then now timeout will happen
Exceptions:
OSError exceptions.
Returns:
void

void CP_Socket::Send const CP_String inMessage  ) 
 

Sends data over the socket connection.

Parameters:
inMessage The data being sent.
Exceptions:
OSError exceptions.
Returns:
void

void CP_Socket::Send const void *  inData,
UInt32  inDataLength
 

Sends data over the socket connection.

Parameters:
inData Pointer to a buffer to send.
inDataLength Amount of data from the buffer to send.
Exceptions:
OSError exceptions.
Returns:
void

SInt32 CP_Socket::Receive void *  inOutBuffer,
UInt32  inOutBufferLength
 

Receives data from the socket connection.

Parameters:
inOutBuffer Location to return the data in.
inOutBufferLength Maximum amount of data to be read at one time.
Exceptions:
OSError exceptions.
Returns:
SInt32 The actual size of data read.

UInt32 CP_Socket::Available  )  const
 

Returns the number of bytes available on the socket connection.

Exceptions:
none 
Returns:
UInt32 The number of available bytes.

bool CP_Socket::HasBytesAvailable  )  const
 

Returns if there are bytes available at the socket connection.

Exceptions:
none 
Returns:
bool const true if there are bytes available

UInt32 CP_Socket::GetHostByName const CP_String inHostName  )  [static]
 

Returns the host from the passed in host name.

Parameters:
inHostName Name of the host to return.
Exceptions:
OSError exceptions.
Returns:
UInt32 The host returned from the host name.

CP_NetworkAddress CP_Socket::GetHostAddressByName const CP_String inHostName  )  [static]
 

Returns the host from the passed in host name.

Parameters:
inHostName Name of the host to return.
Exceptions:
OSError exceptions.
Returns:
CP_NetworkAddress The host returned from the host name.

UInt32 CP_Socket::GetAddress  )  const
 

Return an UInt32 containing the address we are communicating over.

Exceptions:
none 
Returns:
UInt32 The return address.

CP_NetworkAddress CP_Socket::GetNetworkAddress  )  const
 

Return an GetNetworkAddress containing the address we are communicating over.

Exceptions:
none 
Returns:
GetNetworkAddress The return address.

UInt32 CP_Socket::GetPeerAddress  )  const
 

Return an UInt32 containing the peer address we are communicating with.

Exceptions:
none 
Returns:
UInt32 The return peer address.

CP_NetworkAddress CP_Socket::GetPeerNetworkAddress  )  const
 

Return a CP_NetworkAddress containing the peer address we are communicating with.

Exceptions:
none 
Returns:
CP_NetworkAddress The return peer address.

UInt16 CP_Socket::GetPort  )  const
 

Returns the port we are communicating over.

Exceptions:
none 
Returns:
UInt16 The port we are communicating over.

UInt16 CP_Socket::GetPeerPort  )  const
 

Returns the port of the peer are communicating with.

Exceptions:
none 
Returns:
UInt16 The peer port we are communicating with.

CP_String CP_Socket::GetHostName  ) 
 

Returns the name of the host as a string.

Exceptions:
none 
Returns:
CP_String The name of the host.

UInt32 CP_Socket::GetHostID  ) 
 

Return an UInt32 containing the peer address we are communicating with.

Exceptions:
none 
Returns:
UInt32 The return peer address.

void CP_Socket::Close  ) 
 

Closes the connection to the socket.

Exceptions:
none 
Returns:
void

void CP_Socket::CloseInput  ) 
 

Closes the input connection of the socket.

Exceptions:
none 
Returns:
void

void CP_Socket::CloseOutput  ) 
 

Closes the output connection of the socket.

Exceptions:
none 
Returns:
void

bool CP_Socket::IsConnected char  rdwr = -1  )  const
 

Return true if we have a current connection.

Exceptions:
none 
Returns:
bool True if we have a connection.

bool CP_Socket::IsConnectionClosed UInt32  inTimeoutInMicroseconds = 10000  )  const
 

Returns if the connection has closed.

Parameters:
inTimeoutInMicroseconds The call will return within this timeout
Exceptions:
none 
Returns:
bool const true if connection is closes

void CP_Socket::Initialize void   )  [protected]
 

Initializes the socket members called from every constructor.

Exceptions:
OSError exceptions.

void CP_Socket::GetConnectedSocketInfo void   )  [protected]
 


Member Data Documentation

CP_String CP_Socket::fHostName [protected]
 

char CP_Socket::fIsConnected [protected]
 

CP_String containing the name of the host.

sockaddr_in CP_Socket::fSocketAddress [protected]
 

flag to indicate if we are currently connected.

hostent* CP_Socket::fnlp_host [protected]
 

a sockaddr_in structure with the current address info.

int CP_Socket::fSocketDescriptor [protected]
 

SOCKET CP_Socket::fSocketDescriptor [protected]
 

CP_NetworkAddress CP_Socket::fConnectedSocketAddress [protected]
 

UInt16 CP_Socket::fConnectedSocketPort [protected]
 

CP_NetworkAddress CP_Socket::fConnectedPeerAddress [protected]
 

UInt16 CP_Socket::fConnectedPeerPort [protected]
 


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:02:14 2005 for CPLAT by  doxygen 1.4.0