summaryrefslogtreecommitdiff
path: root/src/libc/include/sys/socket.h
blob: e3a47529421ad40ddd0078263b96d40a86e3b9fe (plain)
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
#pragma once
#include <stdint.h>
#include <unistd.h> // ssize_t

typedef int socklen_t;
typedef int sa_family_t;
typedef uint32_t in_addr_t;
typedef uint16_t in_port_t;

#define AF_UNSPEC 0
#define AF_UNIX 1
#define AF_INET 4
#define PF_INET 4

struct sockaddr {
	sa_family_t sa_family;
	char sa_data[];
};

#define SOCK_STREAM 1
#define SOCK_DGRAM 2
int socket(int domain, int type, int protocol);
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int listen(int sockfd, int backlog);

int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
ssize_t send(int sockfd, const void *buf, size_t len, int flags);
ssize_t recv(int sockfd, void *buf, size_t len, int flags);

#define SOL_SOCKET 1
#define SO_KEEPALIVE 1
#define SO_REUSEADDR 2

int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
 
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);