Portability Libraries  2015.2.0.0
Common Methods and Objects for Platform Independance.
Manage a TCP server connection.

The TcpServer object is used along with the Poll object.

Full documentation at TcpServer

Here is an example of a pthread method that starts a TCP server.

void *
MainThread(void * vArg)
int16_t * PortP = (int16_t*)vArg;
int16_t Port = *PortP;
if (PortP != NULL) {
DebugPrintf(1, "TCP Server started on port %hd\n", Port);
// The Poll object is used to register and dispatch
// events from the system ::poll() call.
TcpPollSet = new Poll();
// Call TcpAcceptCallback() each time a new client connects
// to this server. (Set the User Accept Callback)
// Instanciate the TcpServer object.
// This starts the real thread on Port. You can use
// Tcp->AddPort(PortNumber), to add ports to listen to
// @note This call starts a NEW thread.
// Get the socket file descriptor that TcpServer is using
int AcceptFd = Tcp->GetAcceptFd(Port);
int TurnOn = 1;
// If the server crashes, enable re-using the port as valid
// within the TCP 2 minute timeout.
setsockopt(AcceptFd, SOL_SOCKET, SO_REUSEADDR, &TurnOn, 1);