#include "lscp/socket.h"
#include "lscp/event.h"
Go to the source code of this file.
typedef struct _lscp_connect_list_t lscp_connect_list_t |
Client connection list struct.
typedef enum _lscp_connect_mode_t lscp_connect_mode_t |
Connection mode notification.
typedef struct _lscp_connect_t lscp_connect_t |
Client connection descriptor struct.
typedef enum _lscp_server_mode_t lscp_server_mode_t |
Server thread model.
typedef lscp_status_t(* lscp_server_proc_t)(lscp_connect_t *pConnect, const char *pchBuffer, int cchBuffer, void *pvData) |
Server callback procedure prototype.
typedef struct _lscp_server_t lscp_server_t |
Server descriptor struct.
enum _lscp_connect_mode_t |
enum _lscp_server_mode_t |
lscp_status_t lscp_server_broadcast | ( | lscp_server_t * | pServer, | |
lscp_event_t | event, | |||
const char * | pchData, | |||
int | cchData | |||
) |
Send an event notification message to all subscribed clients.
pServer | Pointer to server instance structure. | |
event | Event type flag to send to all subscribed clients. | |
pchData | Pointer to event data to be sent to all clients. | |
cchData | Length of the event data to be sent in bytes. |
References _lscp_connect_t::client, _lscp_server_t::connects, _lscp_connect_t::events, _lscp_connect_list_t::first, LSCP_BUFSIZ, lscp_event_to_text(), lscp_mutex_lock, lscp_mutex_unlock, _lscp_connect_list_t::mutex, _lscp_connect_t::next, and _lscp_socket_agent_t::sock.
Referenced by main().
const char* lscp_server_build | ( | void | ) |
Retrieve the current server library build timestamp string.
Referenced by server_callback(), and server_usage().
lscp_server_t* lscp_server_create | ( | int | iPort, | |
lscp_server_proc_t | pfnCallback, | |||
void * | pvData | |||
) |
Create a server instance, listening on the given port for client connections. A server callback function must be suplied that will handle every and each client request.
iPort | Port number where the server will bind for listening. | |
pfnCallback | Callback function to receive and handle client requests. | |
pvData | Server context opaque data, that will be passed to the callback function without change. |
References lscp_server_create_ex(), and LSCP_SERVER_SELECT.
Referenced by main().
lscp_server_t* lscp_server_create_ex | ( | int | iPort, | |
lscp_server_proc_t | pfnCallback, | |||
void * | pvData, | |||
lscp_server_mode_t | mode | |||
) |
Create a server instance, listening on the given port for client connections. A server callback function must be suplied that will handle every and each client request. A server threading model maybe specified either as multi-threaded (one thread per client) or single thread multiplex mode (one thread serves all clients).
iPort | Port number where the server will bind for listening. | |
pfnCallback | Callback function to receive and handle client requests. | |
pvData | Server context opaque data, that will be passed to the callback function without change. | |
mode | Server mode of operation, regarding the internal threading model, either LSCP_SERVER_THREAD for a multi-threaded server, or LSCP_SERVER_SELECT for a single-threaded multiplexed server. |
References _lscp_socket_agent_t::addr, _lscp_server_t::agent, closesocket, _lscp_server_t::connects, INVALID_SOCKET, LSCP_OK, lscp_socket_agent_free(), lscp_socket_agent_init(), lscp_socket_agent_start(), lscp_socket_getopts(), lscp_socket_perror(), _lscp_server_t::mode, _lscp_server_t::pfnCallback, _lscp_server_t::pvData, _lscp_socket_agent_t::sock, and SOCKET_ERROR.
Referenced by lscp_server_create().
lscp_status_t lscp_server_destroy | ( | lscp_server_t * | pServer | ) |
Terminate and destroy a server instance.
pServer | Pointer to server instance structure. |
References _lscp_server_t::agent, _lscp_server_t::connects, and lscp_socket_agent_free().
Referenced by main().
lscp_status_t lscp_server_join | ( | lscp_server_t * | pServer | ) |
Wait for a server instance to terminate graciously.
pServer | Pointer to server instance structure. |
References _lscp_server_t::agent, and lscp_socket_agent_join().
const char* lscp_server_package | ( | void | ) |
Retrieve the current server library version string.
Referenced by server_callback(), and server_usage().
lscp_status_t lscp_server_result | ( | lscp_connect_t * | pConnect, | |
const char * | pchBuffer, | |||
int | cchBuffer | |||
) |
Send response for the current client callback request.
pConnect | Pointer to client connection instance structure. | |
pchBuffer | Pointer to data to be sent to the client as response. | |
cchBuffer | Length of the response data to be sent in bytes. |
References _lscp_connect_t::client, lscp_socket_perror(), and _lscp_socket_agent_t::sock.
Referenced by server_callback().
lscp_status_t lscp_server_subscribe | ( | lscp_connect_t * | pConnect, | |
lscp_event_t | event | |||
) |
Register client as a subscriber of event broadcast messages.
pConnect | Pointer to client connection instance structure. | |
event | Event type flag of the requesting client subscription. |
References _lscp_connect_t::events, and LSCP_EVENT_NONE.
Referenced by server_callback().
lscp_status_t lscp_server_unsubscribe | ( | lscp_connect_t * | pConnect, | |
lscp_event_t | event | |||
) |
Deregister client as subscriber of event broadcast messages.
pConnect | Pointer to client connection instance structure. | |
event | Event type flag of the requesting client unsubscription. |
References _lscp_connect_t::events, and LSCP_EVENT_NONE.
Referenced by server_callback().
const char* lscp_server_version | ( | void | ) |
Retrieve the current server library version string.
Referenced by server_callback(), and server_usage().