11#include <sys/socket.h>
12#include <netinet/in.h>
22#pragma comment(lib, "ws2_32.lib")
24#pragma warning(disable:4996)
31 #define LISTEN_COUNT 5
32 #define SELECT_TIMEOUT 1
33 #define RECV_DEFAULT_TIMEOUT 5000
34 #define BLOCK_SIZE 1024
73 struct sockaddr_in addrSer;
74 struct sockaddr_in addrCli;
77 sockaddr_in addrSer{};
78 sockaddr_in addrCli{};
81 unsigned short int port;
92 explicit SocketGenerator(
unsigned short int port = 0, std::string ip =
"",
bool mode =
true);
96 void Init(
bool update,
unsigned short int port = 0, std::string ip =
"");
102 int RecvData(
int s,
char *buf,
int len);
104 int SendData(
int s,
char *buf,
int len);
106 void CloseSock(
int s);
117 int TcpRecvBytes(SocketGenerator *s,
char *buf,
size_t len,
bool *stopped =
nullptr);
119 int TcpSendBytes(SocketGenerator *s,
char *buf,
size_t len,
bool *stopped =
nullptr);
unsigned short int GetPort() const
int TcpRecvBytes(SocketGenerator *s, char *buf, size_t len, bool *stopped=nullptr)
int TcpSendBytes(SocketGenerator *s, char *buf, size_t len, bool *stopped=nullptr)