socket_recv4(3diet)

socket_recv43diet

Receive a udp datagram

Usage

#include <socket.h>

ssize_t socket_recv4(int s, char* buf, size_t len,
char ip[4],uint16* port);

Overview

socket_recv4 receives up to len bytes starting at buf from a UDP datagram coming in on the socket s. It writes the UDP port to port and the IP address to ip, and returns the number of bytes actually received (or -1 if anything went wrong).

Return value

socket_recv4 returns the number of bytes in the datagram if one was received. If not, it returns -1 and sets errno appropriately.

Examples

#include <socket.h>

int s;
char ip[4];
uint16 p;
char buf[1000];
int len;

s = socket_tcp4();
socket_bind4(s,ip,p);
len = socket_recv4(s,buf,sizeof(buf),ip,&p);

Releases

4 releases since Debian 3.1 (Sarge); the text changed 1 time.

  1. 3.1–4.0
  2. 5.0–6.0

From libowfat-dev 0.28-2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.