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

MCStreamSocket Class Reference

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

#include <mcllib/MCSocket.h>

Inheritance diagram for MCStreamSocket:

MCCOSocket MCSocket MCIOBase MCBase MCTCPSocket List of all members.

Public Member Functions

virtual void accept (MCStreamSocket *pSock, mcinterval_t timeout=MCIntervalInfinite)
 Accept an incoming connection.
bool getKeepAlive () const
 Determine whether keepalives are active.
bool getLinger () const
 Determine whether linger is enabled on the socket.
mcinterval_t getLingerTime () const
 Determine the linger time of the socket.
mcuint32 getMss () const
 Get the maximum segment size for the socket.
bool getNoDelay () const
 Determine if no delay is enabled.
void listen (mcintn queueLength)
 Put the socket into the listening state ready for accept()ing connections.
void setKeepAlive (bool keepAlive)
 Control whether keepalives are active.
void setLinger (bool linger, mcinterval_t timeout)
 Control whether linger is enabled on the socket.
void setMss (mcuint32 mss)
 Set the maximum segment size for the socket.
void setNoDelay (bool noDelay)
 Control delay behaviour of the socket.
void shutdownRecv ()
 Shutdown receive side of the socket.
void shutdownSend ()
 Shutdown send side of the socket.
virtual ~MCStreamSocket ()
 virtual destructor

Protected Member Functions

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

Detailed Description

Base class for connection-oriented stream sockets.


Constructor & Destructor Documentation

MCStreamSocket void *  impl  )  [protected]
 

Construct from an implementation.

The implementation object must be derived from MCStreamSockBaseImpl


Member Function Documentation

virtual void accept MCStreamSocket pSock,
mcinterval_t  timeout = MCIntervalInfinite
[virtual]
 

Accept an incoming connection.

Accept the first connection request on the queue of a listening socket. The listen() method must be called first with the length of the queue to put the bound socket into a listening state. If the accept fails for any reason an exception is thrown.

Parameters:
pSock the address of a stream socket of the same type as this listening socket. This parameter must not be NULL. On return pSock is initialized with a connected socket over which communication can proceed with the connected peer.
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.

bool getKeepAlive  )  const
 

Determine whether keepalives are active.

Returns:
true if keepalives are active

bool getLinger  )  const
 

Determine whether linger is enabled on the socket.

Returns:
true if linger is enabled.

mcinterval_t getLingerTime  )  const
 

Determine the linger time of the socket.

Returns:
the linger time in milliseconds. If linger is not enabled, the returned linger time is meaningless.

mcuint32 getMss  )  const
 

Get the maximum segment size for the socket.

Returns:
the maximum segment size.

bool getNoDelay  )  const
 

Determine if no delay is enabled.

Returns:
true if no delay is enabled

void listen mcintn  queueLength  ) 
 

Put the socket into the listening state ready for accept()ing connections.

Parameters:
queueLength the maximum number of pending connections that can be waiting to be accept()ed. If more connections are waiting to be accepted the than queueLength, they will be rejected by the host operating system.

void setKeepAlive bool  keepAlive  ) 
 

Control whether keepalives are active.

If keep-alives are enabled, special keep-alive messages are sent periodically to ensure the connection remains active and is not shutdown by the remote end. The frequency with which keep-alive messages are sent and the delay before the first keep-alive is sent are controlled by the operating system and cannot be set by the library.

Parameters:
keepAlive if true keep-alive messages are enabled

void setLinger bool  linger,
mcinterval_t  timeout
 

Control whether linger is enabled on the socket.

If linger is enabled a close() or shutdown() will not return until all queued messages for the socket have been successfully sent or the linger timeout (in milliseconds) has been reached. If linger is disabled a close() or shutdown() returns immediately and any queued messages are sent in the background.

Parameters:
linger enable longer on the socket
timeout the linger timeout in milliseconds

void setMss mcuint32  mss  ) 
 

Set the maximum segment size for the socket.

Parameters:
mss the maximum segment size for the socket.

void setNoDelay bool  noDelay  ) 
 

Control delay behaviour of the socket.

If no delay is enabled any data sent to the socket will be transmitted immediately. If no delay is disabled data sent to the socket will be transparently queued so that fewer transmissions are made to the remote socket. This can severly impact performance in request/response protocols with small messages requiring minimum latency. However, queueing data will result in higher throughput (better bandwidth utilization).

Parameters:
noDelay if true then data will not be queued up but will be sent immediately


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