libctru  v2.4.1
socket.h
1 #pragma once
2 
3 #include <stdint.h>
4 #include <sys/time.h>
5 
6 #define SOL_SOCKET 0xFFFF
7 
8 #define PF_UNSPEC 0
9 #define PF_INET 2
10 #define PF_INET6 23
11 
12 #define AF_UNSPEC PF_UNSPEC
13 #define AF_INET PF_INET
14 #define AF_INET6 PF_INET6
15 
16 #define SOCK_STREAM 1
17 #define SOCK_DGRAM 2
18 
19 // any flags > 0x4 causes send/recv to return EOPNOTSUPP
20 #define MSG_OOB 0x0001
21 #define MSG_PEEK 0x0002
22 #define MSG_DONTWAIT 0x0004
23 #define MSG_DONTROUTE 0x0000 // ???
24 #define MSG_WAITALL 0x0000 // ???
25 #define MSG_MORE 0x0000 // ???
26 #define MSG_NOSIGNAL 0x0000 // there are no signals
27 
28 #define SHUT_RD 0
29 #define SHUT_WR 1
30 #define SHUT_RDWR 2
31 
32 /*
33  * SOL_SOCKET options
34  */
35 #define SO_REUSEADDR 0x0004 // reuse address
36 #define SO_LINGER 0x0080 // linger (no effect?)
37 #define SO_OOBINLINE 0x0100 // out-of-band data inline (no effect?)
38 #define SO_SNDBUF 0x1001 // send buffer size
39 #define SO_RCVBUF 0x1002 // receive buffer size
40 #define SO_SNDLOWAT 0x1003 // send low-water mark (no effect?)
41 #define SO_RCVLOWAT 0x1004 // receive low-water mark
42 #define SO_TYPE 0x1008 // get socket type
43 #define SO_ERROR 0x1009 // get socket error
44 
45 #define SO_BROADCAST 0x0000 // unrequired, included for compatibility
46 
47 #define _SOCKLEN_T_DECLARED
48 
49 typedef uint32_t socklen_t;
50 typedef uint16_t sa_family_t;
51 
52 struct sockaddr {
53  sa_family_t sa_family;
54  char sa_data[];
55 };
56 
57 // biggest size on 3ds is 0x1C (sockaddr_in6)
59  sa_family_t ss_family;
60  char __ss_padding[26];
61 };
62 
63 struct linger {
64  int l_onoff;
65  int l_linger;
66 };
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72  int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
73  int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
74  int closesocket(int sockfd);
75  int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
76  int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
77  int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
78  int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
79  int listen(int sockfd, int backlog);
80  ssize_t recv(int sockfd, void *buf, size_t len, int flags);
81  ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);
82  ssize_t send(int sockfd, const void *buf, size_t len, int flags);
83  ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
84  int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
85  int shutdown(int sockfd, int how);
86  int socket(int domain, int type, int protocol);
87  int sockatmark(int sockfd);
88 
89 #ifdef __cplusplus
90 }
91 #endif
Definition: socket.h:63
Definition: socket.h:58
Definition: socket.h:52