Data Fields | |
void(* | server_ready )(vtm_socket_stream_srv *srv, struct vtm_socket_stream_srv_opts *opts) |
void(* | worker_init )(vtm_socket_stream_srv *srv, vtm_dataset *wd) |
void(* | worker_end )(vtm_socket_stream_srv *srv, vtm_dataset *wd) |
void(* | sock_connected )(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
void(* | sock_disconnected )(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
void(* | sock_can_read )(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
void(* | sock_can_write )(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
void(* | sock_error )(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
Holds the user defined callbacks for a stream server.
When a specific callback is not needed, then is MUST be set to NULL.
Unless otherwise stated each callback function is called from a worker-thread. When the server runs in single-threaded mode, the functions are called from the main thread that started the server.
void(* vtm_socket_stream_srv_cbs::server_ready)(vtm_socket_stream_srv *srv, struct vtm_socket_stream_srv_opts *opts) |
This function is called when the socket of the server was successfully created and is ready to accept incoming connections.
The function is called in the same thread that called vtm_socket_stream_srv_run().
srv | the server which is ready |
opts | the options with which the server was started |
void(* vtm_socket_stream_srv_cbs::worker_init)(vtm_socket_stream_srv *srv, vtm_dataset *wd) |
This function is is called during startup phase of the server for each worker thread.
srv | the server |
wd | an empty dataset set. The same dataset is later delivered to this thread in the other callbacks. You can store things here that may be used during processing of client messages, for example a database connection. |
void(* vtm_socket_stream_srv_cbs::worker_end)(vtm_socket_stream_srv *srv, vtm_dataset *wd) |
This function is called during shutdown phase of the server for each worker thread.
srv | the server |
wd | the working dataset |
void(* vtm_socket_stream_srv_cbs::sock_connected)(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
A new client has connected to the server.
srv | the server |
wd | the working dataset |
client | the connected socket representing the client connection |
void(* vtm_socket_stream_srv_cbs::sock_disconnected)(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
A client connection was closed.
srv | the server |
wd | the working dataset |
client | the socket representing the client connection that was closed |
void(* vtm_socket_stream_srv_cbs::sock_can_read)(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
A socket is rwady for reading data.
srv | the server |
wd | the working dataset |
client | the socket that has data available |
void(* vtm_socket_stream_srv_cbs::sock_can_write)(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
A socket is ready for writing data.
srv | the server |
wd | the working dataset |
client | the socket that is ready |
void(* vtm_socket_stream_srv_cbs::sock_error)(vtm_socket_stream_srv *srv, vtm_dataset *wd, vtm_socket *client) |
A socket is in an error state.
srv | the server |
wd | the working dataset |
client | the socket that is in an error state |