1socket_recv4(3) Library Functions Manual socket_recv4(3)
2
3
4
6 socket_recv4 - receive a UDP datagram
7
9 #include <socket.h>
10
11 ssize_t socket_recv4(int s, char* buf, size_t len,
12 char ip[4],uint16* port);
13
15 socket_recv4 receives up to len bytes starting at buf from a UDP data‐
16 gram coming in on the socket s. It writes the UDP port to port and the
17 IP address to ip, and returns the number of bytes actually received (or
18 -1 if anything went wrong).
19
21 socket_recv4 returns the number of bytes in the datagram if one was
22 received. If not, it returns -1 and sets errno appropriately.
23
25 #include <socket.h>
26
27 int s;
28 char ip[4];
29 uint16 p;
30 char buf[1000];
31 int len;
32
33 s = socket_tcp4();
34 socket_bind4(s,ip,p);
35 len = socket_recv4(s,buf,sizeof(buf),ip,&p);
36
37
39 socket_recv6(3)
40
41
42
43 socket_recv4(3)