2020-09-07 19:58:54 -04:00
|
|
|
#ifdef __linux
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#elif _WIN32
|
|
|
|
#include <WinSock2.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __linux
|
|
|
|
const int TCP_SOCKET_LEVEL = SOL_TCP;
|
|
|
|
#elif _WIN32
|
2020-09-08 00:01:46 -04:00
|
|
|
const int TCP_SOCKET_LEVEL = IPPROTO_TCP;
|
2020-09-07 19:58:54 -04:00
|
|
|
#endif
|
|
|
|
|
2020-09-08 00:01:46 -04:00
|
|
|
int open_socket(int af, int type, int protocol);
|
2020-09-07 19:58:54 -04:00
|
|
|
void close_socket(int sock);
|
2020-09-08 00:01:46 -04:00
|
|
|
int set_socket_option(int socket, int level, int optname, const char* optval, int optlen);
|
2020-09-08 14:17:15 -04:00
|
|
|
int set_socket_timeout(int socket, int microSeconds);
|
2020-09-07 19:58:54 -04:00
|
|
|
int write_to_socket(int socket, const char* buf, int len);
|
|
|
|
int read_from_socket(int socket, char* buf, int len);
|