WUT  0.1
Wii U Toolchain
socket.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <stdint.h>
4 #include <sys/time.h>
5 #include <sys/socket.h>
6 
13 #define SOL_SOCKET 0xFFFF
14 
15 #define PF_UNSPEC 0
16 #define PF_INET 2
17 #define PF_INET6 23
18 
19 #define AF_UNSPEC PF_UNSPEC
20 #define AF_INET PF_INET
21 #define AF_INET6 PF_INET6
22 
23 #define SOCK_STREAM 1
24 #define SOCK_DGRAM 2
25 
26 #define MSG_OOB 0x0001
27 #define MSG_PEEK 0x0002
28 #define MSG_DONTWAIT 0x0004
29 #define MSG_DONTROUTE 0x0000 // ???
30 #define MSG_WAITALL 0x0000 // ???
31 #define MSG_MORE 0x0000 // ???
32 #define MSG_NOSIGNAL 0x0000 // there are no signals
33 
34 #define SHUT_RD 0
35 #define SHUT_WR 1
36 #define SHUT_RDWR 2
37 
38 /*
39  * SOL_SOCKET options
40  */
41 #define SO_REUSEADDR 0x0004 // reuse address
42 #define SO_LINGER 0x0080 // linger (no effect?)
43 #define SO_OOBINLINE 0x0100 // out-of-band data inline (no effect?)
44 #define SO_SNDBUF 0x1001 // send buffer size
45 #define SO_RCVBUF 0x1002 // receive buffer size
46 #define SO_SNDLOWAT 0x1003 // send low-water mark (no effect?)
47 #define SO_RCVLOWAT 0x1004 // receive low-water mark
48 #define SO_TYPE 0x1008 // get socket type
49 #define SO_ERROR 0x1009 // get socket error
50 
51 typedef uint32_t socklen_t;
52 typedef uint16_t sa_family_t;
53 
54 struct sockaddr
55 {
57  char sa_data[];
58 };
59 
61 {
63  char __ss_padding[26];
64 };
65 
66 struct linger
67 {
68  int l_onoff;
69  int l_linger;
70 };
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 void
78 
79 int
80 accept(int sockfd,
81  struct sockaddr *addr,
82  socklen_t *addrlen);
83 
84 int
85 bind(int sockfd,
86  const struct sockaddr *addr,
87  socklen_t addrlen);
88 
89 int
90 closesocket(int sockfd);
91 
92 int
93 connect(int sockfd,
94  const struct sockaddr *addr,
95  socklen_t addrlen);
96 
97 int
98 getpeername(int sockfd,
99  struct sockaddr *addr,
100  socklen_t *addrlen);
101 
102 int
103 getsockname(int sockfd,
104  struct sockaddr *addr,
105  socklen_t *addrlen);
106 
107 int
108 getsockopt(int sockfd,
109  int level,
110  int optname,
111  void *optval,
112  socklen_t *optlen);
113 
114 int
115 listen(int sockfd,
116  int backlog);
117 
118 ssize_t
119 recv(int sockfd,
120  void *buf,
121  size_t len,
122  int flags);
123 
124 ssize_t
125 recvfrom(int sockfd,
126  void *buf,
127  size_t len,
128  int flags,
129  struct sockaddr *src_addr,
130  socklen_t *addrlen);
131 
132 ssize_t
133 send(int sockfd,
134  const void *buf,
135  size_t len,
136  int flags);
137 
138 ssize_t
139 sendto(int sockfd,
140  const void *buf,
141  size_t len,
142  int flags,
143  const struct sockaddr *dest_addr,
144  socklen_t addrlen);
145 
146 int
147 setsockopt(int sockfd,
148  int level,
149  int optname,
150  const void *optval,
151  socklen_t optlen);
152 
153 int
154 shutdown(int sockfd,
155  int how);
156 
157 int
158 socket(int domain,
159  int type,
160  int protocol);
161 
162 int
163 select(int nfds,
164  fd_set *readfds,
165  fd_set *writefds,
166  fd_set *exceptfds,
167  struct timeval *timeout);
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 
int listen(int sockfd, int backlog)
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
sa_family_t ss_family
Definition: socket.h:62
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
char __ss_padding[26]
Definition: socket.h:63
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
uint16_t sa_family_t
Definition: socket.h:52
int l_linger
Definition: socket.h:69
int socket(int domain, int type, int protocol)
Definition: socket.h:66
int l_onoff
Definition: socket.h:68
void socket_lib_init()
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
char sa_data[]
Definition: socket.h:57
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
sa_family_t sa_family
Definition: socket.h:56
uint32_t socklen_t
Definition: socket.h:51
int closesocket(int sockfd)
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
int shutdown(int sockfd, int how)