156
"C" Programming Guide For Optimus S/R
See Also
recvfrom, select, send, socket_hasdata
recvfrom
Purpose
To receive data from a socket and stores the source address.
Syntax
int recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from,
int *fromlen);
s
Descriptor identifying the socket
buf
Pointer to the buffer in which data is received
len
Maximum number of bytes to be received
flags
MSG_OOB: process out-of-band data
MSG_PEEK: peek at incoming data
from
Pointer to a sockaddr structure that will hold the source address
upon return
fromlen
Pointer to an integer containing the length of
from
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
returns urgent data (out-of-bound data)
MSG_PEEK
returns data but do not remove it from buffer,
allowing it to be read again on subsequent calls
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.
See Also
recv, select, send, socket_hasdata
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...