lmsg::SocketPool Class Reference
[DMT message facility]

Reusable socket pool. More...

#include <SocketPool.hh>

List of all members.

Public Types

enum  requestType { s_new, s_reusable }
 Socket request type. More...

Public Member Functions

 ~SocketPool (void)
 Destructor.
 SocketPool (void)
 default constructor.
SocketgetSocket (requestType type, const MsgAddr *addr=0)
 Get a socket from the pool.
void returnSocket (Socket *s)
 Return a socket.


Detailed Description

Reusable socket pool.

The SocketPool class holds client sockets that hav already been opened and may be reused for client connections.

Author:
John Zweizig
Version:
1.2; Last modified March 4, 2008

Member Enumeration Documentation

enum lmsg::SocketPool::requestType

Socket request type.

Socket request type enumeration.
ValueMeaning
s_newAllocate a new socket and bind it to the specified address.
s_reusableGet a socket from the pool if available


Constructor & Destructor Documentation

lmsg::SocketPool::~SocketPool ( void   ) 

Destructor.

Destroy a socket pool and close all remaining sockets.

lmsg::SocketPool::SocketPool ( void   ) 

default constructor.

Create an empty socket pool.


Member Function Documentation

Socket* lmsg::SocketPool::getSocket ( requestType  type,
const MsgAddr addr = 0 
)

Get a socket from the pool.

Get a socket from the pool. If a new socket is requested (i.e. the request type is s_new ) or there are no available sockets in the pool, a new socket is allocated and bound to the specified address. If the IP address or the port number is zero, the socket will be bound to an available ip address and/or port. The socket return address is set to the current pool. If a reusable socket is requested and an idle socket is available, a socket is pulled from the pool.

Parameters:
type Socket type, either s_new or s_reusable.
addr IP address and port to which a new socket is bound.
Returns:
Pointer to the allocated socket descriptor.

void lmsg::SocketPool::returnSocket ( Socket s  ) 

Return a socket.

Return the specified socket to the pool.

Parameters:
s Pointer to the socket descriptor to be returned.


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:35 2009 for dmt by  doxygen 1.5.4