ucommon::ListenSocket Class Reference

A bound socket used to listen for inbound socket connections. More...

#include <socket.h>

Inheritance diagram for ucommon::ListenSocket:
Inheritance graph
[legend]
Collaboration diagram for ucommon::ListenSocket:
Collaboration graph
[legend]

Public Member Functions

socket_t accept (struct sockaddr_storage *address=NULL) const
 Accept a socket connection.
socket_t getsocket (void) const
 Get the socket descriptor of the listener.
 ListenSocket (const char *address, const char *service, unsigned backlog=5, int family=0, int type=0, int protocol=0)
 Create and bind a listener socket.
 operator socket_t () const
 Get the socket descriptor of the listener.
socket_t operator* () const
 Get the socket descriptor of the listener by pointer reference.
bool waitConnection (timeout_t timeout=Timer::inf) const
 Wait for a pending connection.

Static Public Member Functions

static socket_t create (const char *address, const char *service, unsigned backlog=5, int family=0, int type=0, int protocol=0)
 Create a listen socket directly.

Detailed Description

A bound socket used to listen for inbound socket connections.

This class is commonly used for TCP and DCCP listener sockets.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 1660 of file socket.h.


Constructor & Destructor Documentation

ucommon::ListenSocket::ListenSocket ( const char *  address,
const char *  service,
unsigned  backlog = 5,
int  family = 0,
int  type = 0,
int  protocol = 0 
)

Create and bind a listener socket.

Parameters:
address to bind on or "*" for all.
service port to bind listener.
backlog size for buffering pending connections.
family of socket.
type of socket.
protocol for socket if not TCPIP.

Member Function Documentation

socket_t ucommon::ListenSocket::accept ( struct sockaddr_storage *  address = NULL  )  const

Accept a socket connection.

Parameters:
address to save peer connecting.
Returns:
socket descriptor of connected socket.
static socket_t ucommon::ListenSocket::create ( const char *  address,
const char *  service,
unsigned  backlog = 5,
int  family = 0,
int  type = 0,
int  protocol = 0 
) [static]

Create a listen socket directly.

Parameters:
address to bind on or "*" for all.
service port to bind listener.
backlog size for buffering pending connections.
family of socket.
type of socket.
protocol for socket if not TCPIP.
Returns:
bound and listened to socket.
socket_t ucommon::ListenSocket::getsocket ( void   )  const [inline]

Get the socket descriptor of the listener.

Returns:
socket descriptor.

Definition at line 1719 of file socket.h.

ucommon::ListenSocket::operator socket_t (  )  const [inline]

Get the socket descriptor of the listener.

Returns:
socket descriptor.

Reimplemented from ucommon::Socket.

Definition at line 1705 of file socket.h.

socket_t ucommon::ListenSocket::operator* (  )  const [inline]

Get the socket descriptor of the listener by pointer reference.

Returns:
socket descriptor.

Reimplemented from ucommon::Socket.

Definition at line 1712 of file socket.h.

bool ucommon::ListenSocket::waitConnection ( timeout_t  timeout = Timer::inf  )  const [inline]

Wait for a pending connection.

Parameters:
timeout to wait.
Returns:
true when acceptable connection is pending.

Definition at line 1698 of file socket.h.


The documentation for this class was generated from the following file:
Generated on Thu Jul 14 16:39:41 2011 for ucommon by  doxygen 1.6.3