tcplistener Class Reference

Listening TCP socket. More...

#include <tcpsocket.h>

Collaboration diagram for tcplistener:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tcplistener (int port)
 tcplistener (const string &path)
 tcplistener (void)
 ~tcplistener (void)
void listento (int port)
void listento (ipaddress addr, int port)
void listento (const string &path)
tcpsocketaccept (void)
tcpsockettryaccept (double timeout)

Protected Attributes

bool listening
bool tcpdomain
int tcpdomainport
ipaddress bindaddress
string unixdomainpath
lock< int > sock

Detailed Description

Listening TCP socket.

Opens a socket that listens for tcp connections on a configured port. Acts as a factory for connected tcpsocket objects.


Constructor & Destructor Documentation

tcplistener::tcplistener ( int  port  ) 

Constructor.

Parameters:
port TCP port to listen to.
Exceptions:
socketCreateException Error creating a BSD socket.

References listening, and listento().

Here is the call graph for this function:

tcplistener::tcplistener ( const string path  ) 

Constructor.

Parameters:
path Path for the Unix Domain socket.
Exceptions:
socketException Error creating a BSD socket.

References listening, and listento().

Here is the call graph for this function:

tcplistener::~tcplistener ( void   ) 

Constructor.

Delayed initialization constructor. You must excplicitly call one of the listento() methods before going for accept().

References sock.


Member Function Documentation

tcpsocket * tcplistener::accept ( void   ) 

Wait for a new connection.

Returns:
Pointer to a new tcpsocket bound to the connection.
Exceptions:
socketCreateAcception Error creating a BSD socket.

References sock, and tcpdomain.

Referenced by tryaccept().

void tcplistener::listento ( const string path  ) 

Start listening on a Unix socket.

Parameters:
path The Unix path.
Exceptions:
socketCreateException Error creating a BSD socket.

References tune::tcplistener::backlog, listening, sock, string::str(), tcpdomain, filesystem::transw(), and unixdomainpath.

Here is the call graph for this function:

void tcplistener::listento ( ipaddress  addr,
int  port 
)

Start listening on a TCP port at a specific address.

Parameters:
addr The listening address.
port The listening tcp port.
Exceptions:
socketCreateException Error creating a BSD socket.

References tune::tcplistener::backlog, bindaddress, listening, sock, tcpdomain, and tcpdomainport.

void tcplistener::listento ( int  port  ) 

Start listening on a TCP port.

Parameters:
port The TCP port.
Exceptions:
socketCreateException Error creating a BSD socket.

Referenced by smtpd::listento(), httpd::listento(), and tcplistener().

tcpsocket * tcplistener::tryaccept ( double  timeout  ) 

Wait for a new connection.

Parameters:
timeout Timeout in seconds.
Returns:
Pointer to a new tcpsocket bound to the connection, or NULL when it failed.

References accept(), and sock.

Referenced by smtpworker::run(), and httpdworker::run().

Here is the call graph for this function:


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

Generated on Sun Feb 28 10:36:49 2010 for GRACE by  doxygen 1.6.1