Listening TCP socket. More...
#include <tcpsocket.h>

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) |
| tcpsocket * | accept (void) |
| tcpsocket * | tryaccept (double timeout) |
Protected Attributes | |
| bool | listening |
| bool | tcpdomain |
| int | tcpdomainport |
| ipaddress | bindaddress |
| string | unixdomainpath |
| lock< int > | sock |
Listening TCP socket.
Opens a socket that listens for tcp connections on a configured port. Acts as a factory for connected tcpsocket objects.
| tcplistener::tcplistener | ( | int | port | ) |
Constructor.
| port | TCP port to listen to. |
| socketCreateException | Error creating a BSD socket. |
References listening, and listento().

| tcplistener::tcplistener | ( | const string & | path | ) |
Constructor.
| path | Path for the Unix Domain socket. |
| socketException | Error creating a BSD socket. |
References listening, and listento().

| tcplistener::~tcplistener | ( | void | ) |
Constructor.
Delayed initialization constructor. You must excplicitly call one of the listento() methods before going for accept().
References sock.
| tcpsocket * tcplistener::accept | ( | void | ) |
Wait for a new connection.
| 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.
| path | The Unix path. |
| socketCreateException | Error creating a BSD socket. |
References tune::tcplistener::backlog, listening, sock, string::str(), tcpdomain, filesystem::transw(), and unixdomainpath.

| void tcplistener::listento | ( | ipaddress | addr, | |
| int | port | |||
| ) |
Start listening on a TCP port at a specific address.
| addr | The listening address. | |
| port | The listening tcp port. |
| 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.
| port | The TCP port. |
| socketCreateException | Error creating a BSD socket. |
Referenced by smtpd::listento(), httpd::listento(), and tcplistener().
| tcpsocket * tcplistener::tryaccept | ( | double | timeout | ) |
Wait for a new connection.
| timeout | Timeout in seconds. |
References accept(), and sock.
Referenced by smtpworker::run(), and httpdworker::run().

1.6.1