diff options
author | dzwdz | 2023-12-25 18:36:02 +0100 |
---|---|---|
committer | dzwdz | 2023-12-25 18:36:02 +0100 |
commit | 4e1a6f1b3c543b9fbeb882a9e97551f7c58ca65a (patch) | |
tree | 8c2048c751db8b98e3033a61b6ad5bbd11a303a9 /src/libc/include/sys/socket.h | |
parent | 64d4330810a37dd9c41a82ae6cc420850ca1e7da (diff) |
ports: curl :^)
had to do a lot of hacky stuff, but it's there.
worked on this on and off for a while now
Diffstat (limited to 'src/libc/include/sys/socket.h')
-rw-r--r-- | src/libc/include/sys/socket.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libc/include/sys/socket.h b/src/libc/include/sys/socket.h new file mode 100644 index 0000000..e3a4752 --- /dev/null +++ b/src/libc/include/sys/socket.h @@ -0,0 +1,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); |