Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::SocketPeer Class Reference

An abstract class that represents a platform socket implementation. More...

#include <vcf/NetworkKit/Socket.h>

Inheritance diagram for VCF::SocketPeer:

VCF::Win32SocketPeer VCF::Win32UDPSocketPeer List of all members.

Public Member Functions

virtual ~SocketPeer ()
virtual void setPeerOwner (Socket *socket)=0
virtual int create ()=0
virtual int close ()=0
 Closes the OS specific socket handle and releases any resources associated with it.
virtual int connect (const String &host, const unsigned short port)=0
virtual int listen (unsigned short port)=0
virtual SocketPeeraccept ()=0
 Accepts a new connection and returns a new socket peer instance.
virtual int recv (unsigned char *bytes, size_t bytesLength)=0
virtual int send (const unsigned char *bytes, size_t bytesLength)=0
virtual int recvFrom (unsigned char *bytes, size_t bytesLength, IPEndPoint &fromAddr)=0
virtual int sendTo (const unsigned char *bytes, size_t bytesLength, const IPEndPoint &toAddr)=0
virtual OSHandleID getHandleID ()=0
 Returns a handle for the OS specific socket resource.
virtual IPAddress getLocalHostIPAddress ()=0
 Returns the IP address of the local host as a string formatted (for IPV4 at least) as 4 "octets", each separated by the "." character.
virtual IPAddress getRemoteHostIPAddress ()=0
 Returns the IP address of the remote host as a string formatted (for IPV4 at least) as 4 "octets", each separated by the "." character.
virtual unsigned short getLocalPort ()=0
 Returns the local port number for this socket instance.
virtual unsigned short getRemotePort ()=0
 Returns the remote port number for this socket instance.
virtual void setOptions (Dictionary &options)=0
 Sets the options for a socket.
virtual Dictionary getOptions ()=0
 Returns a dictionary containing the options for the socket.
virtual bool wouldOperationBlock ()=0
 Indicates whether the current operation would block.
virtual void select (uint32 timeout, SocketArray *readSockets, SocketArray *writeSockets, SocketArray *errorSockets)=0
 performs a select, using the various read, write, and/or error socket lists.

Detailed Description

An abstract class that represents a platform socket implementation.

This needs to be implemented for each platform that the NetworkKit is portetd to. A typical implementation may use the BSD socket API as a base implementation.


Constructor & Destructor Documentation

virtual VCF::SocketPeer::~SocketPeer  )  [inline, virtual]
 


Member Function Documentation

virtual SocketPeer* VCF::SocketPeer::accept  )  [pure virtual]
 

Accepts a new connection and returns a new socket peer instance.

Assumes the listen() call has already occurred. If it has not then an exception is thrown.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::close  )  [pure virtual]
 

Closes the OS specific socket handle and releases any resources associated with it.

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer.

virtual int VCF::SocketPeer::connect const String host,
const unsigned short  port
[pure virtual]
 

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::create  )  [pure virtual]
 

Creates a new OS specific socket handle. In the simplest case, this would be implemented with the BSD socket() function.
The caller specifies the socket type, which can be either a streaming type (i.e. a socket appropriate for TCP/IP streaming communication), or a datagram type (i.e. a socket appropriate for UPD communication )
Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual OSHandleID VCF::SocketPeer::getHandleID  )  [pure virtual]
 

Returns a handle for the OS specific socket resource.

This is typically a socket handle or descriptor, depending on the OS and the underlying implementation.

Implemented in VCF::Win32SocketPeer.

virtual IPAddress VCF::SocketPeer::getLocalHostIPAddress  )  [pure virtual]
 

Returns the IP address of the local host as a string formatted (for IPV4 at least) as 4 "octets", each separated by the "." character.

Each octet is a number string in the range from 0 to 255.

Implemented in VCF::Win32SocketPeer.

virtual unsigned short VCF::SocketPeer::getLocalPort  )  [pure virtual]
 

Returns the local port number for this socket instance.

Implemented in VCF::Win32SocketPeer.

virtual Dictionary VCF::SocketPeer::getOptions  )  [pure virtual]
 

Returns a dictionary containing the options for the socket.

Implemented in VCF::Win32SocketPeer.

virtual IPAddress VCF::SocketPeer::getRemoteHostIPAddress  )  [pure virtual]
 

Returns the IP address of the remote host as a string formatted (for IPV4 at least) as 4 "octets", each separated by the "." character.

Each octet is a number string in the range from 0 to 255.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual unsigned short VCF::SocketPeer::getRemotePort  )  [pure virtual]
 

Returns the remote port number for this socket instance.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::listen unsigned short  port  )  [pure virtual]
 

Note: bind is implicitly done here.
Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::recv unsigned char *  bytes,
size_t  bytesLength
[pure virtual]
 

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::recvFrom unsigned char *  bytes,
size_t  bytesLength,
IPEndPoint fromAddr
[pure virtual]
 

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual void VCF::SocketPeer::select uint32  timeout,
SocketArray readSockets,
SocketArray writeSockets,
SocketArray errorSockets
[pure virtual]
 

performs a select, using the various read, write, and/or error socket lists.

Will block for a maximum of timeout milliseconds. If the all the read, write, and error socket arrays are NULL, then the select is performed only on the socket instance itself.

Parameters:
uint32 the maximum number of milliseconds to wait for.
See also:
Socket::SelectNoWait,

Socket::SelectWaitForever

Parameters:
SocketArray a pointer to a vector of Socket instances to test whether or not they can be read from. This may vector may be null if the caller is not interested in read notifications. Note that the contents of the vector may change. You may pass in 10 sockets to test, and only get back 3 that are actually ready to be read from.
SocketArray a pointer to a vector of Socket instances to test whether or not they may be written to. This may vector may be null if the caller is not interested in write notifications. Note that the contents of the vector may change. You may pass in 10 sockets to test, and only get back 3 that are actually ready to be written to.
SocketArray a pointer to a vector of Socket instances to test whether or not they have errors. This may vector may be null if the caller is not interested in write notifications. Note that the contents of the vector may change. You may pass in 10 sockets to test, and only get back 3 that are actually in an error state.

Implemented in VCF::Win32SocketPeer.

virtual int VCF::SocketPeer::send const unsigned char *  bytes,
size_t  bytesLength
[pure virtual]
 

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual int VCF::SocketPeer::sendTo const unsigned char *  bytes,
size_t  bytesLength,
const IPEndPoint toAddr
[pure virtual]
 

Returns:
int Returns a 0 for success, otherwise a negative number to indicate an error.

Implemented in VCF::Win32SocketPeer, and VCF::Win32UDPSocketPeer.

virtual void VCF::SocketPeer::setOptions Dictionary options  )  [pure virtual]
 

Sets the options for a socket.

The options are stored as a dictionary of items, with the keys being 1 or more values represented by the Socket::soXXX const string variables.

Implemented in VCF::Win32SocketPeer.

virtual void VCF::SocketPeer::setPeerOwner Socket socket  )  [pure virtual]
 

Implemented in VCF::Win32SocketPeer.

virtual bool VCF::SocketPeer::wouldOperationBlock  )  [pure virtual]
 

Indicates whether the current operation would block.

Assumes a non blocking socket. This is roughly equivalent to getting a an EWOULDBLOCK or WSAEWOULDBLOCK error number.

Returns:
bool True if the operation would block, otherwise false if it would not.

Implemented in VCF::Win32SocketPeer.


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information