#include <SocketPool.hh>
Public Types | |
| enum | requestType { s_new, s_reusable } |
| Socket request type. More... | |
Public Member Functions | |
| ~SocketPool (void) | |
| Destructor. | |
| SocketPool (void) | |
| default constructor. | |
| Socket * | getSocket (requestType type, const MsgAddr *addr=0) |
| Get a socket from the pool. | |
| void | returnSocket (Socket *s) |
| Return a socket. | |
The SocketPool class holds client sockets that hav already been opened and may be reused for client connections.
| 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.
| 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.
| type | Socket type, either s_new or s_reusable. | |
| addr | IP address and port to which a new socket is bound. |
| void lmsg::SocketPool::returnSocket | ( | Socket * | s | ) |
Return a socket.
Return the specified socket to the pool.
| s | Pointer to the socket descriptor to be returned. |
1.5.4