修复使用mingw32编译不通过的问题

pull/396/head
王昂 3 years ago
parent 15398c9ab5
commit 6997befbb3

@ -160,6 +160,26 @@ setSocketNonBlocking(Socket self)
setsockopt(self->fd, IPPROTO_TCP, TCP_NODELAY, (const char*)&tcpNoDelay, sizeof(int)); setsockopt(self->fd, IPPROTO_TCP, TCP_NODELAY, (const char*)&tcpNoDelay, sizeof(int));
} }
#ifdef __i386__
const char*
inet_ntop(int af, const void* src, char* dst, int cnt){
struct sockaddr_in srcaddr;
memset(&srcaddr, 0, sizeof(struct sockaddr_in));
memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr));
srcaddr.sin_family = af;
if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) {
DWORD rv = WSAGetLastError();
printf("WSAAddressToString() : %d\n",rv);
return NULL;
}
return dst;
}
#endif
static bool static bool
prepareAddress(const char *address, int port, struct sockaddr_in *sockaddr) prepareAddress(const char *address, int port, struct sockaddr_in *sockaddr)
{ {

Loading…
Cancel
Save