DCSModulesAPI  1.0.0
DCS sub project containing all the control modules as libraries.
Enumerations | Functions
DCS::Network::Server Namespace Reference

Server-side handling features. More...

Enumerations

enum  StopMode { StopMode::IMMEDIATE, StopMode::WAIT }
 Dictates how the server thread should stop. More...
 

Functions

DCS_API Socket Create (i32 port)
 Create server listening port. More...
 
DCS_API void WaitForConnections (Socket server)
 Wait for any client to connect to the server connection Socket. More...
 
DCS_API void StopListening (Socket server)
 Closes the server listening socket, no longer accepting new connections. More...
 
DCS_API bool StartThread (Socket client)
 Starts the server thread on a established connection. More...
 
DCS_API void StopThread (Socket client, StopMode mode=StopMode::IMMEDIATE)
 Stops the server thread on a established connection (Forces disconnect). More...
 
DCS_API Socket GetConnectedClient ()
 Returns the currently server connected client.
 
DCS_API Socket GetListenSocket ()
 Returns the server listen socket.
 
DCS_API bool IsRunning ()
 Checks if the server is running.
 

Detailed Description

Server-side handling features.

Enumeration Type Documentation

Dictates how the server thread should stop.

Enumerator
IMMEDIATE 

Stop server thread without waiting for the client to disconnect (force shutdown server-side).

WAIT 

Stop server after waiting for the client to disconnect (blocking the calling thread).

Function Documentation

DCS::Network::Socket DCS::Network::Server::Create ( i32  port)

Create server listening port.

Parameters
portPort to bind the server.
Examples:
sockets/simple_server.cpp.
bool DCS::Network::Server::StartThread ( Socket  client)

Starts the server thread on a established connection.

Parameters
clientThe connection between server and client returned by WaitForConnection(Socket).
Returns
Thread init success.
Examples:
sockets/simple_server.cpp.
void DCS::Network::Server::StopListening ( Socket  server)

Closes the server listening socket, no longer accepting new connections.

Parameters
serverCreated server socket to perform the operation.
void DCS::Network::Server::StopThread ( Socket  client,
StopMode  mode = StopMode::IMMEDIATE 
)

Stops the server thread on a established connection (Forces disconnect).

Parameters
clientThe connection between server and client that is currently active.
modeHow the server thread stops (view StopMode).
Examples:
sockets/simple_server.cpp.
void DCS::Network::Server::WaitForConnections ( Socket  server)

Wait for any client to connect to the server connection Socket.

Parameters
serverCreated server socket to wait on.