#ifndef PBXB64_C17_WINSOCK2_H
#define PBXB64_C17_WINSOCK2_H
#include <windows.h>

typedef unsigned long SOCKET;
typedef unsigned short ADDRESS_FAMILY;
typedef unsigned short u_short;
typedef unsigned long u_long;
typedef unsigned int u_int;
typedef char* caddr_t;

typedef struct WSAData { WORD wVersion; WORD wHighVersion; char szDescription[257]; char szSystemStatus[129]; unsigned short iMaxSockets; unsigned short iMaxUdpDg; char *lpVendorInfo; } WSADATA;
typedef struct sockaddr { ADDRESS_FAMILY sa_family; char sa_data[14]; } SOCKADDR;
typedef struct in_addr { unsigned long s_addr; } IN_ADDR;
typedef struct sockaddr_in { short sin_family; unsigned short sin_port; IN_ADDR sin_addr; char sin_zero[8]; } SOCKADDR_IN;
struct hostent { char *h_name; char **h_aliases; short h_addrtype; short h_length; char *h_addr; char **h_addr_list; };

#define INVALID_SOCKET ((SOCKET)(~0u))
#define SOCKET_ERROR (-1)
#define AF_INET 2
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define SD_BOTH 2
#define INADDR_ANY 0u

int WSAStartup(WORD wVersionRequested, WSADATA *lpWSAData);
int WSACleanup(void);
SOCKET socket(int af, int type, int protocol);
int closesocket(SOCKET s);
int connect(SOCKET s, const struct sockaddr *name, int namelen);
int bind(SOCKET s, const struct sockaddr *name, int namelen);
int listen(SOCKET s, int backlog);
SOCKET accept(SOCKET s, struct sockaddr *addr, int *addrlen);
int send(SOCKET s, const char *buf, int len, int flags);
int recv(SOCKET s, char *buf, int len, int flags);
int sendto(SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen);
int recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen);
int gethostname(char *name, int namelen);
unsigned short htons(unsigned short hostshort);
unsigned long htonl(unsigned long hostlong);
unsigned short ntohs(unsigned short netshort);
unsigned long ntohl(unsigned long netlong);
unsigned long inet_addr(const char *cp);
struct hostent *gethostbyname(const char *name);

#endif
