Metrologic Optimus S Programming Manual page 162

"c" programming guide
Table of Contents

Advertisement

156
"C" Programming Guide For Optimus S/R
recvfrom
recvfrom, select, send, socket_hasdata
See Also
To receive data from a socket and stores the source address.
Purpose
Syntax
int recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from,
int *fromlen);
s
buf
len
flags
from
fromlen
Example
(?)
Description
This routine reads incoming data from a specified buffer (buf), and captures the
address from which the data was sent. It is typically used on a connectionless
socket.
The flags argument allows one of the following values:
MSG_OOB
MSG_PEEK
If from is not a null pointer, the source address of data is filled in.
The fromlen argument is a value-result argument, initialized to the size of
the buffer associated with from, and modified on return to indicate the
actual size of the address stored there.
The select() routine may be used to determine when more data arrives. (?)
Note that this is a blocking function. This routine will not return unless for the
following reason:
an error happens
data is received
the receive action times out
The application can avoid this blocking behavior by using socket_hasdata() to
make sure there is data available before calling recvfrom(). (?)
Return
If successful, it returns a non-negative integer (>=0) indicating the number of
bytes received and stored into buffer.
On error, it returns -1.
The global variable errno is set to indicate the error condition encountered.
recv, select, send, socket_hasdata
See Also
Descriptor identifying the socket
Pointer to the buffer in which data is received
Maximum number of bytes to be received
MSG_OOB: process out-of-band data
MSG_PEEK: peek at incoming data
Pointer to a sockaddr structure that will hold the source address
upon return
Pointer to an integer containing the length of from
returns urgent data (out-of-bound data)
returns data but do not remove it from buffer,
allowing it to be read again on subsequent calls

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents