add socket_udp4b and socket_udp6b

master
leitner 9 years ago
parent 32a312b8f1
commit f74f9b9b25

@ -14,9 +14,11 @@ extern "C" {
int socket_tcp4(void); int socket_tcp4(void);
int socket_tcp4b(void); int socket_tcp4b(void);
int socket_udp4(void); int socket_udp4(void);
int socket_udp4b(void);
int socket_tcp6(void); int socket_tcp6(void);
int socket_tcp6b(void); int socket_tcp6b(void);
int socket_udp6(void); int socket_udp6(void);
int socket_udp6b(void);
int socket_sctp4(void); int socket_sctp4(void);
int socket_sctp4b(void); int socket_sctp4b(void);

@ -9,11 +9,16 @@
#include "socket.h" #include "socket.h"
#include "ndelay.h" #include "ndelay.h"
int socket_udp4(void) { int socket_udp4b(void) {
int s; int s;
__winsock_init(); __winsock_init();
s = winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP)); s = winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP));
if (s == -1) return -1; return s;
if (ndelay_on(s) == -1) { close(s); return -1; } }
int socket_udp4(void) {
int s;
s=socket_udp4b();
if (s!=-1 && ndelay_on(s) == -1) { close(s); return -1; }
return s; return s;
} }

@ -20,7 +20,7 @@
#define EPROTONOSUPPORT EAFNOSUPPORT #define EPROTONOSUPPORT EAFNOSUPPORT
#endif #endif
int socket_udp6(void) int socket_udp6b(void)
{ {
#ifdef LIBC_HAS_IP6 #ifdef LIBC_HAS_IP6
int s; int s;
@ -43,9 +43,14 @@ compat:
winsock2errno(setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero))); winsock2errno(setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)));
} }
#endif #endif
if (ndelay_on(s) == -1) { close(s); return -1; }
return s; return s;
#else #else
return socket_udp(); return socket_udp4b();
#endif #endif
} }
int socket_udp6(void) {
int s=socket_udp6b();
if (s!=-1 && ndelay_on(s) == -1) { close(s); return -1; }
return s;
}

3
t.c

@ -68,10 +68,13 @@ static int ret1(const char* s,void* foo) {
} }
int main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
int s=socket_udp6();
#if 0
char buf[100]; char buf[100];
assert(fmt_varint(buf,1)==1 && buf[0]==1); assert(fmt_varint(buf,1)==1 && buf[0]==1);
fmt_varint(buf,300); fmt_varint(buf,300);
assert(fmt_varint(buf,300)==2 && buf[0]==(char)0xac && buf[1]==0x02); assert(fmt_varint(buf,300)==2 && buf[0]==(char)0xac && buf[1]==0x02);
#endif
#if 0 #if 0
const char buf[]="fnord\n"; const char buf[]="fnord\n";
buffer_puts(buffer_1,buf); buffer_puts(buffer_1,buf);

Loading…
Cancel
Save