make socket_(tc|ud)p[46] actually return non-blocking sockets as
documented (Richard Lyons)
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
#include <sys/types.h>
|
||||
#ifndef __MINGW32__
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "windoze.h"
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
int socket_tcp4(void) {
|
||||
int s;
|
||||
__winsock_init();
|
||||
return winsock2errno(socket(PF_INET,SOCK_STREAM,IPPROTO_TCP));
|
||||
s = winsock2errno(socket(PF_INET,SOCK_STREAM,IPPROTO_TCP));
|
||||
if (s == -1) return -1;
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ int socket_tcp6(void)
|
||||
if (s == -1) {
|
||||
if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT || errno == EPROTONOSUPPORT) {
|
||||
compat:
|
||||
s=socket(AF_INET,SOCK_STREAM,0);
|
||||
s=winsock2errno(socket(AF_INET,SOCK_STREAM,0));
|
||||
noipv6=1;
|
||||
if (s==-1) return -1;
|
||||
} else
|
||||
@@ -41,6 +41,7 @@ compat:
|
||||
winsock2errno(setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)));
|
||||
}
|
||||
#endif
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
#else
|
||||
return socket_tcp4();
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#include <sys/types.h>
|
||||
#ifndef __MINGW32__
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "windoze.h"
|
||||
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
int socket_udp4(void) {
|
||||
int s;
|
||||
__winsock_init();
|
||||
return winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP));
|
||||
s = winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP));
|
||||
if (s == -1) return -1;
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ compat:
|
||||
winsock2errno(setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)));
|
||||
}
|
||||
#endif
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
#else
|
||||
return socket_udp();
|
||||
|
||||
Reference in New Issue
Block a user