Closed jamesmasika closed 3 years ago
TcpdirectTcpServer server; server.init(interface, listenIp, port); using TcpConnection = TcpdirectTcpConnection; using TcpConnectionPtr = std::unique_ptr<TcpConnection>; TcpConnectionPtr client; while(client == nullptr) { client = server.accept(); }; struct sockaddr_in c_addr; client->getPeername(c_addr); printf("clientip:%s\n",inet_ntoa(c_addr.sin_addr)); int write_size = __SWP32(pHead->MsgLen) + 3 * sizeof(UINT32); int nwrite = client->write(pMsg, write_size); if(nwrite != write_size){ printf("send 300111 error %s\n", client->getLastError()); //printf("erro no = %s\n", strerror(errno)); continue; }
output: clientip:20.20.1.83 send 300111 error send 300111 error send 300111 error send 300111 error
是不是获取client后还需要做什么操作?
error zft_send_single EAGAIN Resource temporarily unavailable
write的返回值类型是bool不是int
output: clientip:20.20.1.83 send 300111 error send 300111 error send 300111 error send 300111 error