1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
.TH qlibs: socket_udp 3
.SH NAME
socket_udp \- setting up UDP datagram sockets
.SH SYNTAX
.B #include \(dqsocket_if.h\(dq
int \fBsocket_udp4\fP();
.br
int \fBsocket_udp6\fP();
.br
int \fBsocket_udp\fP();
.SH DESCRIPTION
.B socket_udp4
creates a non-blocking UDP/IPv4 datagram socket and
providing a file descriptor pointing to that socket.
.B socket_udp6
creates a non-blocking UDP/IPv6 datagram socket and
providing a file descriptor pointing to that socket.
.B socket_udp
creates a non-blocking IPv6 UDP socket calling
.B socket_udp6
unless it can't bind to IPv6 and now facilitating
.BR socket_tcp4 .
.SH "REMOTE CODES"
All these routines return
.IR 0
except in case of failures, returning
.I -1
and setting
.I errno
appropriately, without allocating any resources.
.SH EXAMPLE
#include <socket_if.h>
int \fIu\fR;
char \fIlocalip\fR[16];
char \fIremoteip\fR[16];
uint16 \fIp\fR; // port
if (ip6_isv4mapped(remoteip)) {
u = socket_udp4();
socket_bind4(u,localip + 12,p);
} else
u = socket_udp6();
socket_bind6(u,localip,p,0);
}
socket_connect(u,remoteip,p,0);
.SH "SEE ALSO"
socket_if(3),
socket_bind(3),
socket_connect(3),
socket_info(3),
socket_recv(3),
socket_send(3),
socket_setup(3),
socket_tcp(3)
|