Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_network.h
Go to the documentation of this file.
1
9#ifndef N_NETWORK
10#define N_NETWORK
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
21#include "n_common.h"
22#include "n_str.h"
23#include "n_list.h"
24#include "n_hash.h"
25
27#define NETWORK_IPALL 0
29#define NETWORK_IPV4 1
31#define NETWORK_IPV6 2
33#define NETWORK_DEPLETE_SOCKET_TIMEOUT 512
35#define NETWORK_DEPLETE_QUEUES_TIMEOUT 1024
37#define NETWORK_CONSECUTIVE_SEND_WAIT 2048
39#define NETWORK_WAIT_CLOSE_TIMEOUT 4096
41#define HEAD_SIZE 10
43#define HEAD_CODE 3
45#define NETW_SOCKET_ERROR -1
47#define NETW_SOCKET_DISCONNECTED -2
49#define NETW_MAX_RETRIES 8
51#define NETW_RETRY_DELAY 1000
52
53#ifndef SOCKET
55#ifdef __windows__
56#ifndef ARCH32BITS
58typedef long long unsigned int SOCKET;
60#define SOCKET_SIZE_FORMAT "%zu"
61#endif
62#else
64typedef int SOCKET;
66#define SOCKET_SIZE_FORMAT "%d"
67#endif
68#endif
69
70#if defined(__linux__) || defined(__sun) || defined(_AIX)
71#include <sys/types.h>
72#include <fcntl.h>
73#include <stdio.h>
74#include <errno.h>
75#include <unistd.h>
76#include <malloc.h>
77#include <string.h>
78#include <netinet/in.h>
79#include <netinet/tcp.h>
80#include <arpa/inet.h>
81#include <netdb.h>
82#include <sys/ioctl.h>
83#include <sys/socket.h>
84#include <semaphore.h>
85
87#define SOCKET_SIZE_FORMAT "%d"
88
89#ifdef __linux__
90#include <linux/sockios.h>
91#include <signal.h>
92#endif
93
94#define netw_unload()
95
97#define closesocket close
99#define NETFLAGS MSG_NOSIGNAL /* for program to not quit under linux when a connection is crashing 2 times */
101#define INVALID_SOCKET -1
102
103#include "n_time.h"
104
105#elif defined __windows__
106
107#define SHUT_WR SD_SEND
108#define SHUT_RD SD_RECEIVE
109#define SHUT_RDWR SD_BOTH
110
111#ifndef ECONNRESET
112#define ECONNRESET 104
113#endif
114
115#if (_WIN32_WINNT < 0x0501)
116#undef _WIN32_WINNT
117#define _WIN32_WINNT 0x0501
118#endif
119
120#include <errno.h>
121#include <unistd.h>
122#include <malloc.h>
123#include <string.h>
124#include <winsock2.h>
125#include <windows.h>
126#include <ws2tcpip.h>
127#include "n_time.h"
128
129#ifndef MSG_EOR
130#define MSG_EOR 0
131#endif
132
133#ifndef MSG_NOSIGNAL
134#define MSG_NOSIGNAL 0
135#endif
136
137#ifndef MSG_WAITALL
138#define MSG_WAITALL 0
139#endif
140
141#ifndef EAI_SYSTEM
142#define EAI_SYSTEM 0
143#endif
144
145#ifndef AI_PASSIVE
146#define AI_PASSIVE 0x00000001
147#endif
148#ifndef AI_CANONNAME
149#define AI_CANONNAME 0x00000002
150#endif
151#ifndef AI_NUMERICHOST
152#define AI_NUMERICHOST 0x00000004
153#endif
154#ifndef AI_NUMERICSERV
155#define AI_NUMERICSERV 0x00000008
156#endif
157#ifndef AI_ALL
158#define AI_ALL 0x00000100
159#endif
160#ifndef AI_ADDRCONFIG
161#define AI_ADDRCONFIG 0x00000400
162#endif
163#ifndef AI_V4MAPPED
164#define AI_V4MAPPED 0x00000800
165#endif
166#ifndef AI_NON_AUTHORITATIVE
167#define AI_NON_AUTHORITATIVE 0x00004000
168#endif
169#ifndef AI_SECURE
170#define AI_SECURE 0x00008000
171#endif
172#ifndef AI_RETURN_PREFERRED_NAMES
173#define AI_RETURN_PREFERRED_NAMES 0x00010000
174#endif
175
176#include <pthread.h>
177#include <semaphore.h>
178
180#define NETFLAGS 0 /* no flags needed for microsoft */
181
183#define netw_unload() netw_init_wsa(0, 2, 2)
184
185#endif
186
187#ifdef HAVE_OPENSSL
188#define _OPEN_SYS_SOCK_IPV6 1
189#include <openssl/err.h>
190#include <openssl/ssl.h>
191#include <openssl/crypto.h>
192#endif
193
195#define N_ENUM_netw_code_type(_) \
196 _(NETW_CLIENT, 2) \
197 _(NETW_SERVER, 4) \
198 _(NETW_RESTART_TIMER, 8) \
199 _(NETW_EMPTY_SENDBUF, 16) \
200 _(NETW_EMPTY_RECVBUF, 32) \
201 _(NETW_RUN, 64) \
202 _(NETW_EXIT_ASKED, 128) \
203 _(NETW_EXITED, 256) \
204 _(NETW_ERROR, 512) \
205 _(NETW_ENCRYPT_NONE, 1024) \
206 _(NETW_ENCRYPT_OPENSSL, 2048) \
207 _(NETW_THR_ENGINE_STARTED, 4096) \
208 _(NETW_THR_ENGINE_STOPPED, 8192) \
209 _(NETW_DESTROY_RECVBUF, 16384) \
210 _(NETW_DESTROY_SENDBUF, 32768)
211
214
216typedef ssize_t (*netw_func)(void*, char*, uint32_t);
217
219typedef struct N_SOCKET {
221 char* port;
225 char* ip;
226
228 unsigned long int is_blocking;
229
231 struct addrinfo hints;
233 struct addrinfo* rhost;
235 struct sockaddr_storage raddr;
236} N_SOCKET;
237
330
332typedef struct NETWORK_POOL {
335
337 pthread_rwlock_t rwlock;
338
340
342typedef struct NETWORK_HTTP_INFO {
343 // Store content type
344 char content_type[256];
345 // Store content length
347 // Pointer to the body data
348 char* body;
349 // Type of request
350 char* type;
352
353/* host to network size_t */
354size_t htonst(size_t value);
355/* network to host size_t */
356size_t ntohst(size_t value);
357#ifdef HAVE_OPENSSL
358/* set SSL */
359int netw_set_crypto(NETWORK* netw, char* key, char* certificate);
360/* init ssl helper */
361int netw_init_openssl(void);
362/* unload ssl helper */
363int netw_unload_openssl(void);
364/* connect ssl helper */
365int netw_ssl_connect(NETWORK** netw, char* host, char* port, int ip_version, char* ssl_key_file, char* ssl_cert_file);
366/* SSL Writting to a socket */
367ssize_t send_ssl_data(void* netw, char* buf, uint32_t n);
368/* SSL Reading from a socket */
369ssize_t recv_ssl_data(void* netw, char* buf, uint32_t n);
370#endif
371/* Used by Init & Close network */
372int netw_init_wsa(int mode, int v1, int v2);
373/* Set flags on network */
374int netw_set(NETWORK* netw, int flag);
375/* Get flags from network */
376int netw_get_state(NETWORK* netw, uint32_t* state, int* thr_engine_status);
377/* Set common socket options (disable naggle, send/recv buf, reuse addr) */
378int netw_setsockopt(NETWORK* netw, int optname, int value);
379/* set blocking mode */
380int netw_set_blocking(NETWORK* netw, unsigned long int is_blocking);
381/* Connecting, extended */
382int netw_connect_ex(NETWORK** netw, char* host, char* port, size_t send_list_limit, size_t recv_list_limit, int ip_version, char* ssl_key_file, char* ssl_cert_file);
383/* Connecting */
384int netw_connect(NETWORK** netw, char* host, char* port, int ip_version);
385/* wait for send buffer to be empty */
386int deplete_send_buffer(int fd, int timeout);
387/* Closing */
388int netw_close(NETWORK** netw);
389/* Closing for peer */
391/* Closing for peer timeouted*/
392int netw_wait_close_timed(NETWORK** netw, size_t timeout);
393/* Stop a NETWORK connection sending and receing thread */
395/* Listening network */
396int netw_make_listening(NETWORK** netw, char* addr, char* port, int nbpending, int ip_version);
397/* Accepting routine extended */
398NETWORK* netw_accept_from_ex(NETWORK* from, size_t send_list_limit, size_t recv_list_limit, int blocking, int* retval);
399/* Accepting routine */
401/* Accepting routine */
402NETWORK* netw_accept_nonblock_from(NETWORK* from, int blocking);
403/* Add a message to send in aimed NETWORK */
404int netw_add_msg(NETWORK* netw, N_STR* msg);
405/* Add a char message to send in the aimed NETWORK */
406int netw_add_msg_ex(NETWORK* netw, char* str, unsigned int length);
407/* Get a message from aimed NETWORK. Instant return to NULL if no MSG */
409/* Wait a message from aimed NETWORK. Recheck each 'refresh' usec until 'timeout' usec */
410N_STR* netw_wait_msg(NETWORK* netw, unsigned int refresh, size_t timeout);
411/* Create the sending and receiving thread of a NETWORK */
413/* Thread Sending management function */
414void* netw_send_func(void* NET);
415/* Thread Receiving management function */
416void* netw_recv_func(void* NET);
417/* Writting to a socket */
418ssize_t send_data(void* netw, char* buf, uint32_t n);
419/* Reading from a socket */
420ssize_t recv_data(void* netw, char* buf, uint32_t n);
421/* sending to php */
422ssize_t send_php(SOCKET s, int _code, char* buf, int n);
423/* receive from php */
424ssize_t recv_php(SOCKET s, int* _code, char** buf);
425/* get queue status */
426int netw_get_queue_status(NETWORK* netw, size_t* nb_to_send, size_t* nb_to_read);
427
428/* init pools */
429NETWORK_POOL* netw_new_pool(size_t nb_min_element);
430/* destroy pool */
431int netw_destroy_pool(NETWORK_POOL** netw_pool);
432/* close pool */
433void netw_pool_netw_close(void* netw_ptr);
434/* add network to pool */
435int netw_pool_add(NETWORK_POOL* netw_pool, NETWORK* netw);
436/* add network to pool */
437int netw_pool_remove(NETWORK_POOL* netw_pool, NETWORK* netw);
438/* add message to pool */
439int netw_pool_broadcast(NETWORK_POOL* netw_pool, NETWORK* from, N_STR* net_msg);
440/* get nb clients */
441size_t netw_pool_nbclients(NETWORK_POOL* netw_pool);
442
443/* set user id on a netw */
444int netw_set_user_id(NETWORK* netw, int id);
445
446/* homemade tcp ip protocol helpers */
447int netw_send_ping(NETWORK* netw, int type, int id_from, int id_to, int time);
448int netw_send_ident(NETWORK* netw, int type, int id, N_STR* name, N_STR* passwd);
449int netw_send_position(NETWORK* netw, int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp);
450int netw_send_string_to(NETWORK* netw, int id_to, N_STR* name, N_STR* chan, N_STR* txt, int color);
451int netw_send_string_to_all(NETWORK* netw, N_STR* name, N_STR* chan, N_STR* txt, int color);
453
454/* http helpers */
455size_t netw_calculate_urlencoded_size(const char* str, size_t len);
456char* netw_extract_http_request_type(const char* request);
458int netw_info_destroy(NETWORK_HTTP_INFO http_request);
459char* netw_urlencode(const char* str, size_t len);
460int netw_get_url_from_http_request(const char* request, char* url, size_t size);
461char* netw_urldecode(const char* str);
462HASH_TABLE* netw_parse_post_data(const char* post_data);
463const char* netw_guess_http_content_type(const char* url);
464const char* netw_get_http_status_message(int status_code);
465int netw_get_http_date(char* buffer, size_t buffer_size);
466int netw_build_http_response(N_STR** http_response, int status_code, const char* server_name, const char* content_type, char* additional_headers, N_STR* body);
467
472#ifdef __cplusplus
473}
474#endif
475
476#endif /*#ifndef N_NETWORK*/
int mode
Network for managing conenctions.
Definition ex_network.c:22
NETWORK * netw
Network for server mode, accepting incomming.
Definition ex_network.c:20
char * key
int ip_version
char * addr
char * port
#define N_ENUM_DECLARE(MACRO_DEFINITION, enum_name)
Macro to declare a N_ENUM.
Definition n_enum.h:133
structure of a hash table
Definition n_hash.h:117
Structure of a generic LIST container.
Definition n_list.h:40
A box including a string and his lenght.
Definition n_str.h:39
struct addrinfo * rhost
getaddrinfo results
Definition n_network.h:233
int crypto_mode
tell if the socket have to be encrypted (flags NETW_CRYPTO_*)
Definition n_network.h:269
char * ip
ip of the connected socket
Definition n_network.h:225
N_SOCKET link
networking socket
Definition n_network.h:305
char * certificate
openssl certificate file
Definition n_network.h:299
int threaded_engine_status
Threaded network engine state for this network.
Definition n_network.h:245
size_t content_length
Definition n_network.h:346
pthread_t send_thr
sending thread
Definition n_network.h:313
int nb_pending
Nb pending connection,if listening.
Definition n_network.h:241
int so_reuseaddr
so reuseaddr state
Definition n_network.h:251
pthread_t recv_thr
receiving thread
Definition n_network.h:315
pthread_rwlock_t rwlock
thread safety
Definition n_network.h:337
struct sockaddr_storage raddr
connected remote addr
Definition n_network.h:235
pthread_mutex_t eventbolt
mutex for threaded access of state event
Definition n_network.h:322
const SSL_METHOD * method
SSL method container.
Definition n_network.h:293
int deplete_socket_timeout
deplete socket send buffer timeout ( 0 disabled, > 0 wait for timeout and check unset/unack datas)
Definition n_network.h:279
int deplete_queues_timeout
deplete network queues timeout ( 0 disabled, > 0 wait for timeout and check unset/unack datas)
Definition n_network.h:277
int nb_running_threads
nb running threads, if > 0 thread engine is still running
Definition n_network.h:275
pthread_mutex_t recvbolt
mutex for threaded access of recv buf
Definition n_network.h:320
pthread_mutex_t sendbolt
mutex for threaded access of send_buf
Definition n_network.h:318
int send_queue_consecutive_wait
send queue consecutive pool interval, used when there are still items to send, in usec
Definition n_network.h:249
int so_rcvtimeo
send timeout value
Definition n_network.h:265
int tcpnodelay
state of naggle algorythm, 0 untouched, 1 forcibly disabled
Definition n_network.h:257
SOCKET sock
a normal socket
Definition n_network.h:223
char * port
port of socket
Definition n_network.h:221
LIST * recv_buf
reveicing buffer (for incomming usage)
Definition n_network.h:310
int user_id
if part of a user property, id of the user
Definition n_network.h:273
sem_t send_blocker
block sending func
Definition n_network.h:324
SSL_CTX * ctx
SSL context holder.
Definition n_network.h:295
int so_sndbuf
size of the socket send buffer, 0 untouched, else size in bytes
Definition n_network.h:259
int so_sndtimeo
send timeout value
Definition n_network.h:263
char content_type[256]
Definition n_network.h:344
struct addrinfo hints
address of local machine
Definition n_network.h:231
int so_keepalive
so keepalive state
Definition n_network.h:255
netw_func send_data
send func ptr
Definition n_network.h:287
int addr_infos_loaded
Internal flag to know if we have to free addr infos.
Definition n_network.h:247
uint32_t state
state of the connection , NETW_RUN, NETW_QUIT, NETW_STOP , NETW_ERR
Definition n_network.h:284
LIST * pools
pointers to network pools if members of any
Definition n_network.h:327
char * key
openssl key file
Definition n_network.h:301
SSL * ssl
SSL handle.
Definition n_network.h:297
int so_linger
close lingering value (-1 disabled, 0 force close, >0 linger )
Definition n_network.h:267
unsigned long int is_blocking
flag to quickly check socket mode
Definition n_network.h:228
int crypto_algo
if encryption is on, which one (flags NETW_ENCRYPT_*)
Definition n_network.h:271
HASH_TABLE * pool
table of clients
Definition n_network.h:334
LIST * send_buf
sending buffer (for outgoing queuing )
Definition n_network.h:308
int mode
NETWORK mode , 1 listening, 0 connecting.
Definition n_network.h:243
int so_rcvbuf
size of the socket recv buffer, 0 untouched, else size in bytes
Definition n_network.h:261
netw_func recv_data
receive func ptr
Definition n_network.h:289
int wait_close_timeout
network wait close timeout value ( < 1 disabled, >= 1 timeout sec )
Definition n_network.h:281
int netw_send_string_to_all(NETWORK *netw, N_STR *name, N_STR *chan, N_STR *txt, int color)
Add a string to the network, aiming all server-side users.
Definition n_network.c:3099
int netw_pool_broadcast(NETWORK_POOL *netw_pool, NETWORK *from, N_STR *net_msg)
add net_msg to all network in netork pool
Definition n_network.c:2958
N_STR * netw_get_msg(NETWORK *netw)
Get a message from aimed NETWORK.
Definition n_network.c:1997
int netw_add_msg(NETWORK *netw, N_STR *msg)
Add a message to send in aimed NETWORK.
Definition n_network.c:1930
ssize_t send_ssl_data(void *netw, char *buf, uint32_t n)
send data onto the socket
Definition n_network.c:2483
char * netw_extract_http_request_type(const char *request)
function to extract the request method from an http request
Definition n_network.c:3188
int netw_get_queue_status(NETWORK *netw, size_t *nb_to_send, size_t *nb_to_read)
retrieve network send queue status
Definition n_network.c:2810
int netw_init_wsa(int mode, int v1, int v2)
Do not directly use, internal api.
Definition n_network.c:693
ssize_t send_php(SOCKET s, int _code, char *buf, int n)
send data onto the socket
Definition n_network.c:2616
int netw_stop_thr_engine(NETWORK *netw)
Stop a NETWORK connection sending and receing thread.
Definition n_network.c:2342
char * netw_urlencode(const char *str, size_t len)
function to perform URL encoding
Definition n_network.c:3155
void * netw_send_func(void *NET)
Thread send function.
Definition n_network.c:2104
NETWORK * netw_accept_nonblock_from(NETWORK *from, int blocking)
make a normal blocking 'accept' .
Definition n_network.c:1920
int netw_get_url_from_http_request(const char *request, char *url, size_t size)
Helper function to extract the URL from the HTTP request line.
Definition n_network.c:3303
#define N_ENUM_netw_code_type(_)
Network codes definition.
Definition n_network.h:195
int netw_set_crypto(NETWORK *netw, char *key, char *certificate)
activate SSL encryption on selected network, using key and certificate
Definition n_network.c:1160
int netw_get_http_date(char *buffer, size_t buffer_size)
helper function to generate the current date in HTTP format
Definition n_network.c:3512
NETWORK_POOL * netw_new_pool(size_t nb_min_element)
return a new network pool of nb_min_element
Definition n_network.c:2829
int netw_set_user_id(NETWORK *netw, int id)
associate an id and a network
Definition n_network.c:2999
ssize_t recv_data(void *netw, char *buf, uint32_t n)
recv data from the socket
Definition n_network.c:2432
int netw_init_openssl(void)
Do not directly use, internal api.
Definition n_network.c:1116
ssize_t recv_ssl_data(void *netw, char *buf, uint32_t n)
recv data from the socket
Definition n_network.c:2549
int netw_make_listening(NETWORK **netw, char *addr, char *port, int nbpending, int ip_version)
Make a NETWORK be a Listening network.
Definition n_network.c:1644
int netw_start_thr_engine(NETWORK *netw)
Start the NETWORK netw Threaded Engine.
Definition n_network.c:2069
int netw_destroy_pool(NETWORK_POOL **netw_pool)
free a NETWORK_POOL *pool
Definition n_network.c:2848
int netw_wait_close(NETWORK **netw)
int netw_build_http_response(N_STR **http_response, int status_code, const char *server_name, const char *content_type, char *additional_headers, N_STR *body)
function to dynamically generate an HTTP response
Definition n_network.c:3544
void * netw_recv_func(void *NET)
To Thread Receiving function.
Definition n_network.c:2225
size_t htonst(size_t value)
host to network size_t
Definition n_network.c:30
int netw_unload_openssl(void)
Do not directly use, internal api.
Definition n_network.c:1140
size_t ntohst(size_t value)
network to host size_t
Definition n_network.c:47
ssize_t(* netw_func)(void *, char *, uint32_t)
send/recv func ptr type
Definition n_network.h:216
size_t netw_pool_nbclients(NETWORK_POOL *netw_pool)
return the number of networks in netw_pool
Definition n_network.c:2982
NETWORK * netw_accept_from_ex(NETWORK *from, size_t send_list_limit, size_t recv_list_limit, int blocking, int *retval)
make a normal 'accept' .
Definition n_network.c:1753
int netw_connect_ex(NETWORK **netw, char *host, char *port, size_t send_list_limit, size_t recv_list_limit, int ip_version, char *ssl_key_file, char *ssl_cert_file)
Use this to connect a NETWORK to any listening one.
Definition n_network.c:1222
int SOCKET
default socket declaration
Definition n_network.h:64
int netw_setsockopt(NETWORK *netw, int optname, int value)
Modify common socket options on the given netw.
Definition n_network.c:794
int netw_set(NETWORK *netw, int flag)
Restart or reset the specified network ability.
Definition n_network.c:1409
ssize_t send_data(void *netw, char *buf, uint32_t n)
send data onto the socket
Definition n_network.c:2381
int netw_get_state(NETWORK *netw, uint32_t *state, int *thr_engine_status)
Get the state of a network.
Definition n_network.c:1388
void netw_pool_netw_close(void *netw_ptr)
close a network from a network pool
Definition n_network.c:2867
size_t netw_calculate_urlencoded_size(const char *str, size_t len)
function to calculate the required size for the URL-encoded string
Definition n_network.c:3132
int deplete_send_buffer(int fd, int timeout)
wait until the socket is empty or timeout, checking each 100 msec.
Definition n_network.c:1472
NETWORK * netw_accept_from(NETWORK *from)
make a normal blocking 'accept' .
Definition n_network.c:1910
int netw_close(NETWORK **netw)
Closing a specified Network, destroy queues, free the structure.
Definition n_network.c:1503
int netw_send_quit(NETWORK *netw)
Add a formatted NETMSG_QUIT message to the specified network.
Definition n_network.c:3115
const char * netw_get_http_status_message(int status_code)
helper function to convert status code to a human-readable message
Definition n_network.c:3488
int netw_set_blocking(NETWORK *netw, unsigned long int is_blocking)
Modify blocking socket mode.
Definition n_network.c:739
N_STR * netw_wait_msg(NETWORK *netw, unsigned int refresh, size_t timeout)
Wait a message from aimed NETWORK.
Definition n_network.c:2018
int netw_send_string_to(NETWORK *netw, int id_to, N_STR *name, N_STR *chan, N_STR *txt, int color)
Add a string to the network, aiming a specific user.
Definition n_network.c:3079
int netw_send_ping(NETWORK *netw, int type, int id_from, int id_to, int time)
Add a ping reply to the network.
Definition n_network.c:3014
int netw_ssl_connect(NETWORK **netw, char *host, char *port, int ip_version, char *ssl_key_file, char *ssl_cert_file)
Use this to connect a NETWORK to any listening one, unrestricted send/recv lists.
Definition n_network.c:1375
NETWORK_HTTP_INFO netw_extract_http_info(char *request)
extract a lot of informations, mostly as pointers, and populate a NETWORK_HTTP_INFO structure
Definition n_network.c:3221
int netw_connect(NETWORK **netw, char *host, char *port, int ip_version)
Use this to connect a NETWORK to any listening one, unrestricted send/recv lists.
Definition n_network.c:1359
__netw_code_type
Network codes declaration.
Definition n_network.h:213
int netw_send_ident(NETWORK *netw, int type, int id, N_STR *name, N_STR *passwd)
Add a formatted NETWMSG_IDENT message to the specified network.
Definition n_network.c:3033
char * netw_urldecode(const char *str)
Function to decode URL-encoded data.
Definition n_network.c:3340
int netw_pool_add(NETWORK_POOL *netw_pool, NETWORK *netw)
add a NETWORK *netw to a NETWORK_POOL *pool
Definition n_network.c:2880
int netw_info_destroy(NETWORK_HTTP_INFO http_request)
destroy a NETWORK_HTTP_INFO loaded informations
Definition n_network.c:3290
HASH_TABLE * netw_parse_post_data(const char *post_data)
Function to parse POST data.
Definition n_network.c:3377
const char * netw_guess_http_content_type(const char *url)
function to guess the content type based on URL extension
Definition n_network.c:3424
ssize_t recv_php(SOCKET s, int *_code, char **buf)
recv data from the socket
Definition n_network.c:2699
int netw_send_position(NETWORK *netw, int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp)
Add a formatted NETWMSG_IDENT message to the specified network.
Definition n_network.c:3057
int netw_pool_remove(NETWORK_POOL *netw_pool, NETWORK *netw)
remove a NETWORK *netw to a NETWORK_POOL *pool
Definition n_network.c:2923
int netw_add_msg_ex(NETWORK *netw, char *str, unsigned int length)
Add a message to send in aimed NETWORK.
Definition n_network.c:1961
int netw_wait_close_timed(NETWORK **netw, size_t timeout)
Structure of a N_SOCKET.
Definition n_network.h:219
Structure of a NETWORK.
Definition n_network.h:239
structure for splitting HTTP requests
Definition n_network.h:342
structure of a network pool
Definition n_network.h:332
Common headers and low-level functions & define.
Hash functions and table.
List structures and definitions.
N_STR and string function declaration.
Timing utilities.