Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCCOSocket Class Reference

Base class for connection-oriented sockets. More...

#include <mcllib/MCSocket.h>

Inheritance diagram for MCCOSocket:

MCSocket MCIOBase MCBase MCCOUDPSocket MCStreamSocket MCTCPSocket List of all members.

Public Member Functions

void connect (const MCNetAddr &addr, mcinterval_t timeout=MCIntervalInfinite)
 Establish a connection with a remote address.
MCNetAddr getPeerName () const
 Get the remote address of the socket.
mcint32 peek (void *buf, mcint32 len, mcinterval_t timeout=MCIntervalInfinite)
 Receive data from the connected peer.
mcint32 recv (void *buf, mcint32 len, mcinterval_t timeout=MCIntervalInfinite)
 Receive data from the connected peer.
mcint32 send (const void *buf, mcint32 len, mcinterval_t timeout=MCIntervalInfinite)
 Send data to the connected peer.

Protected Member Functions

 MCCOSocket (void *impl)
 Construct from an implementation.
 MCCOSocket ()
 Default constructor for use by derived classes.

Detailed Description

Base class for connection-oriented sockets.

Connection-oriented sockets have a permanent "peer" to which they are connected. Once connected, the peer to which they are connected cannot be changed.


Constructor & Destructor Documentation

MCCOSocket void *  impl  )  [protected]
 

Construct from an implementation.

The implementation object must be derived from MCCOSockBaseImpl


Member Function Documentation

void connect const MCNetAddr addr,
mcinterval_t  timeout = MCIntervalInfinite
 

Establish a connection with a remote address.

If the connection cannot be established, an exception is thrown.

Parameters:
addr the address of the peer to connect to.
timeout the number of milliseconds to wait for the connection to be established. If the connection cannot be established in the specified time an MCTimedOut exception is thrown.

MCNetAddr getPeerName  )  const
 

Get the remote address of the socket.

The socket must be connected. If the remote socket name cannot be obtained an exception is thrown.

Returns:
an MCNetAddr representing the remote address of the connected socket

mcint32 peek void *  buf,
mcint32  len,
mcinterval_t  timeout = MCIntervalInfinite
 

Receive data from the connected peer.

Same as recv() however the data received is left on the socket for further recv()s or peek()s.

mcint32 recv void *  buf,
mcint32  len,
mcinterval_t  timeout = MCIntervalInfinite
 

Receive data from the connected peer.

If the receive fails an exception is thrown.

Parameters:
buf the buffer into which the data is placed
len the amount of data to receive. Buf must point to a region of memory at least len bytes in size.
timeout the number of milliseconds to wait for the receive to complete. If the receive does not complete within the specified time an MCTimedOut exception is thrown.
Returns:
the number of bytes actually received

mcint32 send const void *  buf,
mcint32  len,
mcinterval_t  timeout = MCIntervalInfinite
 

Send data to the connected peer.

If the send fails an exception is thrown.

Parameters:
buf the buffer containing the data to send
len the amount of data to send. Buf must point to a region of memory at least len bytes in size.
timeout the number of milliseconds to wait for the send to complete. If the send does not complete within the specified time an MCTimedOut exception is thrown.
Returns:
the number of bytes actually sent.


Generated on Wed Jan 12 19:05:49 2005 for MCLLIB by  doxygen 1.3.9.1