add socket_udp4b and socket_udp6b
This commit is contained in:
parent
32a312b8f1
commit
f74f9b9b25
2
socket.h
2
socket.h
@ -14,9 +14,11 @@ extern "C" {
|
||||
int socket_tcp4(void);
|
||||
int socket_tcp4b(void);
|
||||
int socket_udp4(void);
|
||||
int socket_udp4b(void);
|
||||
int socket_tcp6(void);
|
||||
int socket_tcp6b(void);
|
||||
int socket_udp6(void);
|
||||
int socket_udp6b(void);
|
||||
|
||||
int socket_sctp4(void);
|
||||
int socket_sctp4b(void);
|
||||
|
@ -9,11 +9,16 @@
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
int socket_udp4(void) {
|
||||
int socket_udp4b(void) {
|
||||
int s;
|
||||
__winsock_init();
|
||||
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;
|
||||
}
|
||||
|
||||
int socket_udp4(void) {
|
||||
int s;
|
||||
s=socket_udp4b();
|
||||
if (s!=-1 && ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define EPROTONOSUPPORT EAFNOSUPPORT
|
||||
#endif
|
||||
|
||||
int socket_udp6(void)
|
||||
int socket_udp6b(void)
|
||||
{
|
||||
#ifdef LIBC_HAS_IP6
|
||||
int s;
|
||||
@ -43,9 +43,14 @@ 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();
|
||||
return socket_udp4b();
|
||||
#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
3
t.c
@ -68,10 +68,13 @@ static int ret1(const char* s,void* foo) {
|
||||
}
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
int s=socket_udp6();
|
||||
#if 0
|
||||
char buf[100];
|
||||
assert(fmt_varint(buf,1)==1 && buf[0]==1);
|
||||
fmt_varint(buf,300);
|
||||
assert(fmt_varint(buf,300)==2 && buf[0]==(char)0xac && buf[1]==0x02);
|
||||
#endif
|
||||
#if 0
|
||||
const char buf[]="fnord\n";
|
||||
buffer_puts(buffer_1,buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user