Go to the source code of this file.
Classes |
|
class | ServerSocket |
server socket type More... |
|
Enumerations |
|
enum | sstype { ss_udp, ss_tcp, ss_client } |
Functions |
|
void | udpsock_handledata (int sockid) |
Handles data from an UDP server socket. |
|
void | tcpsock_handledata (int sockid) |
Handles data from a TCP server socket. |
|
void | clientsock_handledata (int sockid) |
Handles data from an UDP client socket. |
|
stl_slist (ServerSocket) servers | |
stl_slist (PendingAnswerUDP) pending_answers | |
int | getclientsockid (_addr *a) |
void * | serverthread (void *arg) |
void | posserver_init_srvresolver () |
Initialize server resolver system. |
|
void | posserver_startback () |
Start server in the background. |
|
void | posserver_run () |
Start server in the foreground. |
|
void | posserver_stop () |
Stop the Posadis server. |
|
Variables |
|
pthread_mutex_t | m_servers |
pthread_mutex_t | m_pending_answers |
pthread_cond_t | c_data_received |
int | udp_client_socket |
int | udp_client_socket_6 |
bool(* | allow_tcp_connection )(_addr *a, int ntcp) |
check whether to allow TCP connections |
|
int | n_threads |
Current number of threads. |
|
void(* | user_cleanup_function )(void) |
cleanup function |
Properties for server sockets.
Definition in file serverthread.h.
|
Socket type
Definition at line 39 of file serverthread.h. |
|
Gets UDP client socket appropriate for the given address. |
|
Initialize server resolver system. This initializes the server resolver system used by pos_srvresolver. This might become obsolete in future Poslib releases. |
|
Start server in the foreground. Starts the Posadis server in the foreground. This function does not return until posserver_stop() is called.
|
|
Start server in the background. Starts the Posadis server thread in the background, returning immediately.
|
|
Stop the Posadis server. Stops the Posadis server. This might take some time because it has to wait until all threads are stopped. This will also close down all sockets Poslib listens to, and clear the servers list.
|
|
The main server thread function. |
|
List of pending answers. Internal - no need to edit. |
|
List of sockets the server should listen on. Protected by m_servers. |
|
check whether to allow TCP connections Every time a TCP connection is opened, this function is run to check whether we are willing to provide TCP connectivity to the given client, given the number of TCP processes already active. If the function returns true, the connection is allowed and a new thread is created to handle it. If, on the other hand, it returns false, the connection is closed down directly. The defalt implementation is to allow a TCP connection if n_threads is smaller than max_threads. This function is run with the m_servers mutex locked.
Definition at line 114 of file serverthread.h. |
|
Condition for receiving data on a UDP client socket. Definition at line 92 of file serverthread.h. |
|
Mutex for the #pending_answers list. Definition at line 87 of file serverthread.h. |
|
Mutex for the #server list. Definition at line 78 of file serverthread.h. |
|
Current number of threads. The number of currently active threads. Locked by the m_servers mutex. Definition at line 121 of file serverthread.h. |
|
UDP client socket. Definition at line 94 of file serverthread.h. |
|
UDP client socket (IPv6); Definition at line 95 of file serverthread.h. |
|
cleanup function This is a function to a user function that will be called every once in a while (currently every 5 minutes), that can perform cleanup tasks that take very little time, so that you won't need a separate thread for that. Poslib itself executes a function which cleans up request IDs at this interval, and you can add your own user function to make that be called as well. And I'm going to repeat this: make sure your cleanup function uses very little time because it is executed in the main server thread. This means that while your function is running, new queries will not be answered. Definition at line 137 of file serverthread.h. |