Simple++
Powerfull and lightning fast C++ Library
|
Represent a listening server who can handle multiple protocol or ip family. More...
#include <Server.h>
Public Member Functions | |
Server () | |
Create a new Server. More... | |
~Server () | |
destructor More... | |
bool | listen (unsigned short port, SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined, int maxClients=100) |
Add a listen address to this server. More... | |
bool | listen (const String &address, const String &service, SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined, int maxClients=100) |
Add a listen address to this server. More... | |
bool | listen (const String &address, unsigned int port, SockType sockType=SockType::TCP, IpFamily ipFamily=IpFamily::Undefined, int maxClients=100) |
Add a listen address to this server. More... | |
bool | listen (const Address &addrInfo, int maxClients=100) |
Add a listen address to this server. More... | |
Vector< Connection * >::Size | getNumConnections () const |
get the number of connection this server has More... | |
bool | accept (Connection *clientSocket) |
Accept a new Client from one of the connections (only when listening on TCP) More... | |
bool | close () |
close all the connections More... | |
int | receive (char *buffer, int maxSize, Address *addressFrom) |
Wait to receive a message from one of the connections. More... | |
Static Public Member Functions | |
static size_t | getMaximumNbConnections () |
get the maximum number of connections a server can have. More... | |
Represent a listening server who can handle multiple protocol or ip family.
Network::Server::Server | ( | ) |
Create a new Server.
Network::Server::~Server | ( | ) |
destructor
bool Network::Server::accept | ( | Connection * | clientSocket | ) |
Accept a new Client from one of the connections (only when listening on TCP)
clientSocket | Object to be filled with the incoming client (the object has to be allocated) |
bool Network::Server::close | ( | ) |
close all the connections
|
static |
get the maximum number of connections a server can have.
Vector< Connection * >::Size Network::Server::getNumConnections | ( | ) | const |
get the number of connection this server has
bool Network::Server::listen | ( | unsigned short | port, |
SockType | sockType = SockType::TCP , |
||
IpFamily | ipFamily = IpFamily::Undefined , |
||
int | maxClients = 100 |
||
) |
Add a listen address to this server.
port | Port onto listen. |
sockType | TCP or UDP |
ipFamily | IPv4, IPV6 or Undefined for both |
maxClients | Maximum number of clients accepted (Only for TCP) |
bool Network::Server::listen | ( | const String & | address, |
const String & | service, | ||
SockType | sockType = SockType::TCP , |
||
IpFamily | ipFamily = IpFamily::Undefined , |
||
int | maxClients = 100 |
||
) |
Add a listen address to this server.
address | Address as String (IP or domain name) |
service | to look for. |
sockType | TCP or UDP |
ipFamily | IPv4, IPV6 or Undefined for both |
maxClients | Maximum number of clients accepted (Only for TCP) |
bool Network::Server::listen | ( | const String & | address, |
unsigned int | port, | ||
SockType | sockType = SockType::TCP , |
||
IpFamily | ipFamily = IpFamily::Undefined , |
||
int | maxClients = 100 |
||
) |
Add a listen address to this server.
address | Address as String (IP or domain name) |
port | Port onto listen. |
sockType | TCP or UDP |
ipFamily | IPv4, IPV6 or Undefined for both |
maxClients | Maximum number of clients accepted (Only for TCP) |
bool Network::Server::listen | ( | const Address & | addrInfo, |
int | maxClients = 100 |
||
) |
Add a listen address to this server.
addrInfo | Address to be binded |
maxClients | Maximum number of clients accepted (Only for TCP) |
int Network::Server::receive | ( | char * | buffer, |
int | maxSize, | ||
Address * | addressFrom | ||
) |
Wait to receive a message from one of the connections.
buffer | to be filled with the new message. |
maxSize | Maximum size of the message in bytes |
addressFrom | Address to be filled with the incoming sender (the object has to be already allocated) |