poser
A C framework for POsix SERvices
|
A server listening on a socket and accepting connections. More...
#include <poser/core/server.h>
Public Member Functions | |
PSC_Server * | PSC_Server_createTcp (const PSC_TcpServerOpts *opts) |
Create a TCP server. | |
PSC_Server * | PSC_Server_createUnix (const PSC_UnixServerOpts *opts) |
Create a local UNIX server. | |
PSC_Event * | PSC_Server_clientConnected (PSC_Server *self) |
New client connected. | |
PSC_Event * | PSC_Server_clientDisconnected (PSC_Server *self) |
Client disconnected. | |
void | PSC_Server_disable (PSC_Server *self) |
Disable the server. | |
void | PSC_Server_enable (PSC_Server *self) |
Enable the server. | |
void | PSC_Server_destroy (PSC_Server *self) |
PSC_Server destructor. | |
A server listening on a socket and accepting connections.
This class will open one or multiple listening sockets and handle incoming connections by creating a PSC_Connection for them and firing an event.
PSC_Event * PSC_Server_clientConnected | ( | PSC_Server * | self | ) |
New client connected.
This event fires when a new client connected and the connection was accepted. The PSC_Connection object for the new client is passed as the event arguments.
self | the PSC_Server |
PSC_Event * PSC_Server_clientDisconnected | ( | PSC_Server * | self | ) |
Client disconnected.
This event fires after a connection with a client was closed. The PSC_Connection object of the closed connection is passed as the event arguments.
Note that when you already monitor the closed event of the PSC_Connection, you will probably not need this event.
self | the PSC_Server |
PSC_Server * PSC_Server_createTcp | ( | const PSC_TcpServerOpts * | opts | ) |
Create a TCP server.
opts | TCP server options |
PSC_Server * PSC_Server_createUnix | ( | const PSC_UnixServerOpts * | opts | ) |
Create a local UNIX server.
opts | UNIX server options |
void PSC_Server_destroy | ( | PSC_Server * | self | ) |
PSC_Server destructor.
This will close all active client connections and stop listening.
self | the PSC_Server |
void PSC_Server_disable | ( | PSC_Server * | self | ) |
Disable the server.
This disables accepting new connections while still listening. It's implemented by immediately closing any new connection with a linger timeout of 0, which should be signaled as an error to the client trying to connect. For a TCP server, it means immediately sending an RST packet.
Note this does not affect already existing connections.
self | the PSC_Server |
void PSC_Server_enable | ( | PSC_Server * | self | ) |
Enable the server.
This enables accepting new connections again after PSC_Server_disable() was called.
self | the PSC_Server |