poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_Server Class Reference

A server listening on a socket and accepting connections. More...

#include <poser/core/server.h>

Public Member Functions

PSC_ServerPSC_Server_createTcp (const PSC_TcpServerOpts *opts)
 Create a TCP server.
 
PSC_ServerPSC_Server_createUnix (const PSC_UnixServerOpts *opts)
 Create a local UNIX server.
 
PSC_EventPSC_Server_clientConnected (PSC_Server *self)
 New client connected.
 
PSC_EventPSC_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.
 

Detailed Description

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.

Member Function Documentation

◆ PSC_Server_clientConnected()

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.

Parameters
selfthe PSC_Server
Returns
the client connected event

◆ PSC_Server_clientDisconnected()

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.

Parameters
selfthe PSC_Server
Returns
the client disconnected event

◆ PSC_Server_createTcp()

PSC_Server * PSC_Server_createTcp ( const PSC_TcpServerOpts opts)

Create a TCP server.

Parameters
optsTCP server options
Returns
a newly created server, or NULL on error

◆ PSC_Server_createUnix()

PSC_Server * PSC_Server_createUnix ( const PSC_UnixServerOpts opts)

Create a local UNIX server.

Parameters
optsUNIX server options
Returns
a newly created server, or NULL on error

◆ PSC_Server_destroy()

void PSC_Server_destroy ( PSC_Server self)

PSC_Server destructor.

This will close all active client connections and stop listening.

Parameters
selfthe PSC_Server

◆ PSC_Server_disable()

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.

Parameters
selfthe PSC_Server

◆ PSC_Server_enable()

void PSC_Server_enable ( PSC_Server self)

Enable the server.

This enables accepting new connections again after PSC_Server_disable() was called.

Parameters
selfthe PSC_Server

The documentation for this class was generated from the following file: