File: socket_recv6.3

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (36 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download | duplicates (3)
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
.TH socket_recv6 3
.SH NAME
socket_recv6 \- receive a UDP datagram
.SH SYNTAX
.B #include <libowfat/socket.h>

ssize_t \fBsocket_recv6\fP(int \fIs\fR, char* \fIbuf\fR, size_t \fIlen\fR,
        char \fIip\fR[16], uint16* \fIport\fR, uint32* \fIscope_id\fR);
.SH DESCRIPTION
socket_recv6 receives up to \fIlen\fR bytes starting at \fIbuf\fR from a UDP
datagram coming in on the socket \fIs\fR.  It writes the UDP port to
\fIport\fR and the IP address to \fIip\fR, and returns the number of
bytes actually received (or -1 if anything went wrong).

For link-local addresses, \fIscope_id\fR will become the network
interface number, which can be translated into the name of the interface
("eth0") with socket_getifname.
.SH RETURN VALUE
socket_recv6 returns the number of bytes in the datagram if one was
received.  If not, it returns -1 and sets errno appropriately.
.SH EXAMPLE
  #include <libowfat/socket.h>

  int \fIs\fR;
  char \fIip\fR[16];
  uint16 \fIp\fR;
  char buf[1000];
  int len;
  uint32 scope_id;

  \fIs\fR = socket_tcp4();
  socket_bind6(s,ip,p);
  len = socket_recv6(s,buf,sizeof(buf),ip,&p,&scope_id);

.SH "SEE ALSO"
socket_recv4(3), socket_getifname(3)