make socket_(tc|ud)p[46] actually return non-blocking sockets as

documented (Richard Lyons)
This commit is contained in:
leitner
2006-05-18 06:02:43 +00:00
parent db2ab20d9f
commit d361d81c64
25 changed files with 142 additions and 22 deletions

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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();