5 * License: LGPL 2.1+ with static linking exception
11 #ifndef _ROCKSOCKSERVER_H_
12 #define _ROCKSOCKSERVER_H_
15 #include <sys/socket.h>
16 #include <sys/select.h>
18 #if (! defined(USER_MAX_FD)) || (USER_MAX_FD > FD_SETSIZE)
20 #define USER_MAX_FD FD_SETSIZE
23 typedef void (*perror_func
)(const char*);
35 void rocksockserver_set_sleeptime(rocksockserver
* srv
, long microsecs
);
36 int rocksockserver_disconnect_client(rocksockserver
* srv
, int client
);
37 int rocksockserver_init(rocksockserver
* srv
, const char* listenip
, unsigned short port
, void* userdata
);
38 void rocksockserver_watch_fd(rocksockserver
* srv
, int newfd
);
39 void rocksockserver_set_signalfd(rocksockserver
* srv
, int signalfd
);
40 void rocksockserver_set_perrorfunc(rocksockserver
* srv
, perror_func perr
);
41 int rocksockserver_loop(rocksockserver
* srv
,
42 char* buf
, size_t bufsize
,
43 int (*on_clientconnect
) (void* userdata
, struct sockaddr_storage
* clientaddr
, int fd
),
44 int (*on_clientread
) (void* userdata
, int fd
, size_t nread
),
45 int (*on_clientwantsdata
) (void* userdata
, int fd
),
46 int (*on_clientdisconnect
) (void* userdata
, int fd
)
51 //RcB: DEP "rocksockserver*.c"