UCommon

ListenSocket Class Reference

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

#include <socket.h>

Inheritance diagram for ListenSocket:
Collaboration diagram for ListenSocket:

Public Member Functions

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

Static Public Member Functions

static socket_t create (char *address, char *service, unsigned backlog=5, int family=AF_UNSPEC, 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 1658 of file socket.h.


Constructor & Destructor Documentation

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

Create and bind a listener socket.

Parameters:
addressto bind on or "*" for all.
serviceport to bind listener.
backlogsize for buffering pending connections.
familyof socket.
typeof socket.
protocolfor socket if not TCPIP.

Member Function Documentation

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

Accept a socket connection.

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

Create a listen socket directly.

Parameters:
addressto bind on or "*" for all.
serviceport to bind listener.
backlogsize for buffering pending connections.
familyof socket.
typeof socket.
protocolfor socket if not TCPIP.
Returns:
bound and listened to socket.
socket_t ListenSocket::getsocket ( void  ) [inline]

Get the socket descriptor of the listener.

Returns:
socket descriptor.

Definition at line 1717 of file socket.h.

ListenSocket::operator socket_t ( ) [inline]

Get the socket descriptor of the listener.

Returns:
socket descriptor.

Reimplemented from Socket.

Definition at line 1703 of file socket.h.

socket_t ListenSocket::operator* ( ) [inline]

Get the socket descriptor of the listener by pointer reference.

Returns:
socket descriptor.

Reimplemented from Socket.

Definition at line 1710 of file socket.h.

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

Wait for a pending connection.

Parameters:
timeoutto wait.
Returns:
true when acceptable connection is pending.

Definition at line 1696 of file socket.h.

Here is the call graph for this function:


The documentation for this class was generated from the following file: