-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsocket.h
69 lines (49 loc) · 1.21 KB
/
socket.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
#ifndef __SOCKET_H__
#define __SOCKET_H__
#include <sys/socket.h>
#include <netinet/in.h>
#define SOCKET_ADDR_STRLEN INET6_ADDRSTRLEN
typedef struct {
socklen_t addrlen;
union {
struct sockaddr sa;
struct sockaddr_in si;
struct sockaddr_in6 s6;
struct sockaddr_storage ss;
} addr;
} socket_addr_t;
int
socket_addr(socket_addr_t *addr, char *hostname, int port);
int
socket_addr_str(socket_addr_t *addr, char *addrstr, int *port);
int
socket_open(int domain, int type, int protocol);
int
socket_set_nonblock(int sockfd);
int
socket_set_reuseaddr(int sockfd);
int
socket_set_tcp_nodelay(int sockfd);
int
socket_set_tcp_nopush(int sockfd);
int
socket_set_reuseport(int sockfd);
int
socket_set_pktinfo(int sockfd);
int
socket_bind(int sockfd, socket_addr_t *addr);
int
socket_listen(int sockfd, int backlog);
int
socket_accept(int sockfd, socket_addr_t *addr);
int
socket_connect(int sockfd, socket_addr_t *addr);
ssize_t
socket_recvfromto(int sockfd, void *buf, size_t len, int flags,
socket_addr_t *src, socket_addr_t *dst);
ssize_t
socket_sendtofrom(int sockfd, void *buf, size_t len, int flags,
socket_addr_t *dst, socket_addr_t *src);
int
socket_close(int sockfd);
#endif /* __SOCKET_H__ */