-
Notifications
You must be signed in to change notification settings - Fork 0
/
sockets-handler.h
95 lines (82 loc) · 1.87 KB
/
sockets-handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdbool.h>
#ifndef _SOCKETS_HANDLER_H
#define _SOCKETS_HANDLER_H
/**
* Main loop of clients handling.
*
* @param server_socket Socket for reciveing new clients.
*/
int sockets_poll_loop(int server_socket);
/**
* Destroy sockets loop.
*/
void sockets_destroy(void);
/**
* Adds new socket for processing.
*
* @param socket New socket.
* @param callback Socket handler function.
* @param arg Argument for socket handler.
*
* @return {@code false} if to many sockets already registered.
*/
bool sockets_add_socket(int socket,
void (*callback)(int, int, void*),
void* arg);
/**
* Enable input handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle enabled.
*/
bool sockets_enable_in_handle(int socket);
/**
* Enable output handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle enabled.
*/
bool sockets_enable_out_handle(int socket);
/**
* Enable input/output handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle enabled.
*/
bool sockets_enable_io_handle(int socket);
/**
* Disable input handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle disabled.
*/
bool sockets_cancel_in_handle(int socket);
/**
* Disable output handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle disabled.
*/
bool sockets_cancel_out_handle(int socket);
/**
* Disable input/output handling for added socket.
*
* @param socket Required socket.
*
* @return {@code true} if handle disabled.
*/
bool sockets_cancel_io_handle(int socket);
/**
* Removes socket from processing list.
*
* @param socket Required socket.
*
* @return {@code true} if socket removed.
*/
bool sockets_remove_socket(int socket);
#endif