forked from luncliff/coroutine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet_test.h
More file actions
43 lines (31 loc) · 1.13 KB
/
net_test.h
File metadata and controls
43 lines (31 loc) · 1.13 KB
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
//
// Author : github.com/luncliff (luncliff@gmail.com)
// License : CC BY 4.0
//
#pragma once
#include <coroutine/net.h>
void load_network_api() noexcept(false);
// create 1 socket
int64_t socket_create(const addrinfo& hint);
// create multiple socket
auto socket_create(const addrinfo& hint, size_t count)
-> coro::enumerable<int64_t>;
// dispose given socket
void socket_close(int64_t sd);
// bind the socket to given address
void socket_bind(int64_t sd, endpoint_t& ep);
// start listen with the socket
void socket_listen(int64_t sd);
// try connect to given endpoint
int64_t socket_connect(int64_t sd, const endpoint_t& remote);
// accept a connection request and return client socket
int64_t socket_accept(const int64_t ln, endpoint_t& ep);
// change the socket's option
void socket_set_option(int64_t sd, int64_t level, int64_t option,
int64_t value);
// make socket to operate in non-blocking mode
void socket_set_option_nonblock(int64_t sd);
// make socket to reuse address
void socket_set_option_reuse_address(int64_t sd);
// make tcp send without delay
void socket_set_option_nodelay(int64_t sd);