21 #ifndef __SYS_SOCKET_H
22 #define __SYS_SOCKET_H
24 #include <sys/cdefs.h>
25 #include <sys/types.h>
51 #define _SS_MAXSIZE 128
54 #define _SS_ALIGNSIZE (sizeof(__uint64_t))
57 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(sa_family_t))
60 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof(sa_family_t) + \
61 _SS_PAD1SIZE + _SS_ALIGNSIZE))
121 #define SO_ACCEPTCONN 1
122 #define SO_BROADCAST 2
124 #define SO_DONTROUTE 4
126 #define SO_KEEPALIVE 6
128 #define SO_OOBINLINE 8
130 #define SO_RCVLOWAT 10
131 #define SO_RCVTIMEO 11
132 #define SO_REUSEADDR 12
134 #define SO_SNDLOWAT 14
135 #define SO_SNDTIMEO 15
151 #define MSG_CTRUNC 0x01
152 #define MSG_DONTROUTE 0x02
155 #define MSG_PEEK 0x10
156 #define MSG_TRUNC 0x20
157 #define MSG_WAITALL 0x40
158 #define MSG_DONTWAIT 0x80
171 #define PF_UNSPEC AF_UNSPEC
174 #define PF_INET AF_INET
177 #define PF_INET6 AF_INET6
180 #define SHUT_RD 0x00000001
183 #define SHUT_WR 0x00000002
186 #define SHUT_RDWR (SHUT_RD | SHUT_WR)
262 ssize_t
recv(
int socket,
void *buffer,
size_t length,
int flags);
281 ssize_t
recvfrom(
int socket,
void *buffer,
size_t length,
int flags,
295 ssize_t
send(
int socket,
const void *message,
size_t length,
int flags);
312 ssize_t
sendto(
int socket,
const void *message,
size_t length,
int flags,
341 int socket(
int domain,
int type,
int protocol);
386 int setsockopt(
int socket,
int level,
int option_name,
const void *option_value,
ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
Send a message on a socket.
__uint8_t sa_family_t
Socket address family type.
Definition: socket.h:33
__uint64_t _ss_align
Used to force alignment.
Definition: socket.h:75
int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
Get socket options.
sa_family_t sa_family
Address family.
Definition: socket.h:40
int bind(int socket, const struct sockaddr *address, socklen_t address_len)
Bind a name to a socket.
sa_family_t ss_family
Address family.
Definition: socket.h:69
int shutdown(int socket, int how)
Shutdown socket send and receive operations.
#define _SS_PAD1SIZE
First padding size used within struct sockaddr_storage.
Definition: socket.h:57
#define _SS_PAD2SIZE
Second padding size used within struct sockaddr_storage.
Definition: socket.h:60
char _ss_pad2[_SS_PAD2SIZE]
Second padding field to fill up the space required.
Definition: socket.h:78
ssize_t send(int socket, const void *message, size_t length, int flags)
Send a message on a connected socket.
int listen(int socket, int backlog)
Listen for socket connections and set the queue length.
Socket address structure.
Definition: socket.h:38
ssize_t recv(int socket, void *buffer, size_t length, int flags)
Receive a message on a connected socket.
char sa_data[]
Address data.
Definition: socket.h:42
int accept(int socket, struct sockaddr *address, socklen_t *address_len)
Accept a new connection on a socket.
int connect(int socket, const struct sockaddr *address, socklen_t address_len)
Connect a socket.
Socket address structure of appropriate size to hold any supported socket type's addresses.
Definition: socket.h:67
int socket(int domain, int type, int protocol)
Create an endpoint for communications.
__uint32_t socklen_t
Socket length type.
Definition: socket.h:30
int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
Set socket options.
char _ss_pad1[_SS_PAD1SIZE]
First padding field.
Definition: socket.h:72
ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
Receive a message on a socket.