libdill: Structured Concurrency for C

NAME

udp_recv - receives a UDP packet

SYNOPSIS

#include <libdill.h>

ssize_t udp_recv(int s, struct ipaddr *addr, void *buf, size_t len, int64_t deadline);

ssize_t udp_recvl(int s, struct ipaddr *addr, struct iolist *first, struct iolist *last, int64_t deadline);

DESCRIPTION

UDP is an unreliable message-based protocol. The size of the message is limited. The protocol has no initial or terminal handshake. A single socket can be used to different destinations.

This function receives a single UDP packet. If addr is not NULL, the argument will be filled in by the address of the sender of the packet.

RETURN VALUE

The function returns size of the message on success. On error, it returns -1 and sets errno to one of the values below.

ERRORS

EXAMPLE

char buf[256];
ssize_t sz = udp_recv(s, NULL, buf, sizeof(buf), -1);