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

VCF::Win32SocketPeer Class Reference

#include <Win32SocketPeer.h>

Inheritance diagram for VCF::Win32SocketPeer:

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

Public Member Functions

 Win32SocketPeer ()
 Win32SocketPeer (SOCKET handle)
virtual void setPeerOwner (Socket *socket)
virtual int create ()
virtual int close ()
 Closes the OS specific socket handle and releases any resources associated with it.
virtual int connect (const String &host, const unsigned short port)
virtual int listen (unsigned short port)
virtual SocketPeeraccept ()
 Accepts a new connection and returns a new socket peer instance.
virtual int recv (unsigned char *bytes, size_t bytesLength)
virtual int send (const unsigned char *bytes, size_t bytesLength)
virtual int recvFrom (unsigned char *bytes, size_t bytesLength, IPEndPoint &fromAddr)
virtual int sendTo (const unsigned char *bytes, size_t bytesLength, const IPEndPoint &toAddr)
virtual OSHandleID getHandleID ()
 Returns a handle for the OS specific socket resource.
virtual IPAddress getLocalHostIPAddress ()
 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 unsigned short getLocalPort ()
 Returns the local port number for this socket instance.
virtual IPAddress getRemoteHostIPAddress ()
 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 getRemotePort ()
 Returns the remote port number for this socket instance.
virtual void setOptions (Dictionary &options)
 Sets the options for a socket.
virtual Dictionary getOptions ()
 Returns a dictionary containing the options for the socket.
virtual bool wouldOperationBlock ()
 Indicates whether the current operation would block.
virtual void select (uint32 timeout, SocketArray *readSockets, SocketArray *writeSockets, SocketArray *errorSockets)
 performs a select, using the various read, write, and/or error socket lists.

Protected Attributes

SOCKET handle_
sockaddr_in sockAddr_
Socketsocket_

Constructor & Destructor Documentation

VCF::Win32SocketPeer::Win32SocketPeer  ) 
 

VCF::Win32SocketPeer::Win32SocketPeer SOCKET  handle  ) 
 


Member Function Documentation

virtual SocketPeer* VCF::Win32SocketPeer::accept  )  [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.

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual int VCF::Win32SocketPeer::close  )  [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.

Implements VCF::SocketPeer.

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

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual int VCF::Win32SocketPeer::create  )  [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.

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual OSHandleID VCF::Win32SocketPeer::getHandleID  )  [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.

Implements VCF::SocketPeer.

virtual IPAddress VCF::Win32SocketPeer::getLocalHostIPAddress  )  [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.

Implements VCF::SocketPeer.

virtual unsigned short VCF::Win32SocketPeer::getLocalPort  )  [virtual]
 

Returns the local port number for this socket instance.

Implements VCF::SocketPeer.

virtual Dictionary VCF::Win32SocketPeer::getOptions  )  [virtual]
 

Returns a dictionary containing the options for the socket.

Implements VCF::SocketPeer.

virtual IPAddress VCF::Win32SocketPeer::getRemoteHostIPAddress  )  [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.

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual unsigned short VCF::Win32SocketPeer::getRemotePort  )  [virtual]
 

Returns the remote port number for this socket instance.

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual int VCF::Win32SocketPeer::listen unsigned short  port  )  [virtual]
 

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

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

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

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

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual void VCF::Win32SocketPeer::select uint32  timeout,
SocketArray readSockets,
SocketArray writeSockets,
SocketArray errorSockets
[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.

Implements VCF::SocketPeer.

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

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

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

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

Implements VCF::SocketPeer.

Reimplemented in VCF::Win32UDPSocketPeer.

virtual void VCF::Win32SocketPeer::setOptions Dictionary options  )  [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.

Implements VCF::SocketPeer.

virtual void VCF::Win32SocketPeer::setPeerOwner Socket socket  )  [inline, virtual]
 

Implements VCF::SocketPeer.

virtual bool VCF::Win32SocketPeer::wouldOperationBlock  )  [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.

Implements VCF::SocketPeer.


Member Data Documentation

SOCKET VCF::Win32SocketPeer::handle_ [protected]
 

struct sockaddr_in VCF::Win32SocketPeer::sockAddr_ [protected]
 

Socket* VCF::Win32SocketPeer::socket_ [protected]
 


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