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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
============================================================================
Name : hev-task-io-socket.h
Author : Heiher <r@hev.cc>
Copyright : Copyright (c) 2018 everyone.
Description : Task socket I/O operations
============================================================================
*/
#ifndef __HEV_TASK_IO_SOCKET_H__
#define __HEV_TASK_IO_SOCKET_H__
#include <sys/socket.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* hev_task_io_socket_socket:
* @domain: the communications domain
* @type: the type of socket
* @protocol: a particular protocol to be used with the socket
*
* The socket function shall create an unbound socket in a communications
* domain, and return a file descriptor that can be used in later function calls
* that operate on sockets.
*
* Returns: the socket file descriptor.
*
* Since: 3.3.5
*/
int hev_task_io_socket_socket (int domain, int type, int protocol);
/**
* hev_task_io_socket_socketpair:
* @domain: the communications domain
* @type: the type of socket
* @protocol: a particular protocol to be used with the socket
* @socket_vector: the file descriptors of the created socket pair
*
* The socketpair function shall create an unbound pair of connected sockets in
* a specified @domain, of a specified @type, under the protocol optionally
* specified by the @protocol augument.
*
* Returns: the status of create.
*
* Since: 3.3.5
*/
int hev_task_io_socket_socketpair (int domain, int type, int protocol,
int socket_vector[2]);
/**
* hev_task_io_socket_connect:
* @fd: a file descriptor
* @addr: socket address
* @addr_len: socket address length
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The connect function shall attempt to make a connection on a connection-mode
* socket or to set or reset the peer address of a connectionless-mode socket.
*
* Returns: the status of connect
*
* Since: 3.2
*/
int hev_task_io_socket_connect (int fd, const struct sockaddr *addr,
socklen_t addr_len, HevTaskIOYielder yielder,
void *yielder_data);
/**
* hev_task_io_socket_accept:
* @fd: a file descriptor
* @addr: socket address
* @addr_len: socket address length
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The accept function shall extract the first connection on the queue of
* pending connections, create a new socket with the same socket type protocol
* and address family as the specified socket, and allocate a new file
* descriptor for that socket.
*
* Returns: the file descriptor of accepted socket
*
* Since: 3.2
*/
int hev_task_io_socket_accept (int fd, struct sockaddr *addr,
socklen_t *addr_len, HevTaskIOYielder yielder,
void *yielder_data);
/**
* hev_task_io_socket_recv:
* @fd: a file descriptor
* @buf: buffer
* @len: buffer length
* @flags: flags
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The recv function shall receive a message from a connection-mode or
* connectionless-mode socket. It is normally used with connected sockets
* because it does not permit the application to retrieve the source address of
* received data.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_recv (int fd, void *buf, size_t len, int flags,
HevTaskIOYielder yielder, void *yielder_data);
/**
* hev_task_io_socket_send:
* @fd: a file descriptor
* @buf: buffer
* @len: buffer length
* @flags: flags
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The send function shall initiate transmission of a message from the specified
* socket to its peer. The send function shall send a message only when the
* socket is connected. If the socket is a connectionless-mode socket, the
* message shall be sent to the pre-specified peer address.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_send (int fd, const void *buf, size_t len, int flags,
HevTaskIOYielder yielder, void *yielder_data);
/**
* hev_task_io_socket_recvfrom:
* @fd: a file descriptor
* @buf: buffer
* @len: buffer length
* @flags: flags
* @addr: socket address
* @addr_len: socket address length
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The recvfrom function shall receive a message from a connection-mode or
* connectionless-mode socket. It is normally used with connected sockets
* because it does not permit the application to retrieve the source address of
* received data.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_recvfrom (int fd, void *buf, size_t len, int flags,
struct sockaddr *addr, socklen_t *addr_len,
HevTaskIOYielder yielder,
void *yielder_data);
/**
* hev_task_io_socket_sendto:
* @fd: a file descriptor
* @buf: buffer
* @len: buffer length
* @flags: flags
* @addr: socket address
* @addr_len: socket address length
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The sendto function shall initiate transmission of a message from the
* specified socket to its peer. The send function shall send a message only
* when the socket is connected. If the socket is a connectionless-mode socket,
* the message shall be sent to the pre-specified peer address.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_sendto (int fd, const void *buf, size_t len,
int flags, const struct sockaddr *addr,
socklen_t addr_len, HevTaskIOYielder yielder,
void *yielder_data);
/**
* hev_task_io_socket_recvmsg:
* @fd: a file descriptor
* @msg: message
* @flags: flags
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The recvmsg function shall receive a message from a connection-mode or
* connectionless-mode socket. It is normally used with connected sockets
* because it does not permit the application to retrieve the source address of
* received data.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_recvmsg (int fd, struct msghdr *msg, int flags,
HevTaskIOYielder yielder,
void *yielder_data);
/**
* hev_task_io_socket_sendmsg:
* @fd: a file descriptor
* @msg: message
* @flags: flags
* @yielder: a #HevTaskIOYielder
* @yielder_data: user data
*
* The sendmsg function shall initiate transmission of a message from the
* specified socket to its peer. The send function shall send a message only
* when the socket is connected. If the socket is a connectionless-mode socket,
* the message shall be sent to the pre-specified peer address.
*
* Returns: the length of the message in bytes
*
* Since: 3.2
*/
ssize_t hev_task_io_socket_sendmsg (int fd, const struct msghdr *msg, int flags,
HevTaskIOYielder yielder,
void *yielder_data);
#ifdef __cplusplus
}
#endif
#endif /* __HEV_TASK_IO_SOCKET_H__ */