Serial-TCP/IPbridge
1.0
|
TCPIP server that accepts client connections. More...
#include <tcpip_server.h>
Classes | |
class | TCPIPServerError |
This exception is thrown in case of some server error. More... | |
Public Member Functions | |
TCPIPServer (const TCPIPConfig &config) | |
Constructor. More... | |
~TCPIPServer () | |
Destructor. More... | |
std::auto_ptr< TCPIPConnection > | tryAcceptConnection () |
Tries to accept a TCP/IP connection from a client. More... | |
void | stopListening () |
Stops listening (accepting new connections). More... | |
Private Types | |
typedef std::vector< int > | Sockets |
List of sockets. More... | |
typedef std::vector< std::string > | IPAddresses |
List of IPv4 addresses. More... | |
Private Member Functions | |
TCPIPServer (const TCPIPServer &) | |
TCPIPServer & | operator= (const TCPIPServer &) |
IPAddresses | getAddressesToListenOn (const TCPIPConfig::Interfaces &interfaces) |
Returns a list of IPv4 address on which the server should listen on. More... | |
IPAddresses | getInterfaceAddresses (const std::string &interface) |
Returns all IPv4 address associated with the selected interface. More... | |
Private Attributes | |
const TCPIPConfig | _config |
TCP/IP configuration. More... | |
Sockets | _sockets |
List of sockets on which the server listens. More... | |
Static Private Attributes | |
static const int | MAX_CONNECTION_COUNT |
Maximal incoming connection count. More... | |
TCPIP server that accepts client connections.
This class provides a server which listens on the selected interface and port and accepts client connections.
It provides reference semantics (objects copying and comparison is NOT allowed).
|
private |
List of IPv4 addresses.
|
private |
List of sockets.
|
explicit |
Constructor.
config | TCP/IP configuration. |
Creates and initializes a TCPIPServer object and starts listening (accepting new connections). If there is some error, TCPIPServerError will be thrown.
Server "tryX" operations will be blocking (by default). You can change this by calling setBlocking(false).
TCPIPServer::~TCPIPServer | ( | ) |
Destructor.
|
private |
|
private |
Returns a list of IPv4 address on which the server should listen on.
interfaces | The list of network interfaces and/or IPv4 addresses (or TCPIPConfig::ANY_INTERFACE). |
If one value in the interfaces list is TCPIPConfig::ANY_INTERFACE, then the server should listen on all available interfaces and a list containing one value (TCPIPConfig::ANY_INTERFACE) will be returned.
If there is an error (e.g. IP addresses for some interface cannot be obtained), TCPIPServerError exception will be thrown.
|
private |
Returns all IPv4 address associated with the selected interface.
interface | The network interface. |
If there is an error (e.g. non-existing interface), TCPIPServerError exception will be thrown.
|
private |
void TCPIPServer::stopListening | ( | ) |
Stops listening (accepting new connections).
std::auto_ptr<TCPIPConnection> TCPIPServer::tryAcceptConnection | ( | ) |
Tries to accept a TCP/IP connection from a client.
The behaviour of this operation is nonblocking (i.e., when there is no connection to be accepted, it returns immediately).
In case of a connection error, TCPIPConnection::TCPIPConnectionError exception is thrown.
|
private |
TCP/IP configuration.
|
private |
List of sockets on which the server listens.
|
staticprivate |
Maximal incoming connection count.