16 static int close(
int fd)
18 return closesocket(fd);
23 if (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEWOULDBLOCK) {
24 printf(
"EINTR occured, port=%d, fp=%d, errno=%d\n", port, fp, WSAGetLastError());
27 printf(
"socket read failed, port=%d, fp=%d, errno=%d, exit\n", port, fp, WSAGetLastError());
31 #include <sys/socket.h> 35 if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
36 printf(
"EINTR occured, port=%d, fp=%d, errno=%d\n", port, fp, errno);
39 printf(
"socket read failed, port=%d, fp=%d, errno=%d, exit\n", port, fp, errno);
49 unsigned char *recv_data =
new unsigned char[
que_maxlen_];
65 while (ret != 0 &&
state_ == 0 && failed_cnt < 1500)
67 std::this_thread::sleep_for(std::chrono::milliseconds(2));
73 printf(
"socket push data failed, exit, port=%d, fp=%d\n",
port_,
fp_);
123 if (
state_ != 0) {
return -1; }
int write_frame(unsigned char *data, int len)
int read_frame(unsigned char *data)
static bool is_ignore_errno(int fp, int port)
SocketPort(char *server_ip, int server_port, int que_num, int que_maxlen)
int socket_init(char *local_ip, int port, int is_server)
int socket_connect_server(int *socket, char server_ip[], int server_port)
static void * recv_proc_(void *arg)
int socket_send_data(int client_fp, unsigned char *data, int len)
void bin32_to_8(int a, unsigned char *b)