#pragma once #include #include // 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);