@CHIP-RTOS C Library - TCP/IP API
recvfrom_bsd
Receive a UDP datagram. int far recvfrom_bsd ( int sd,
char far * bufptr,
int buflen,
int flags,
struct sockaddr far * fromPtr,
int far * fromLengthPtr,
unsigned long timeout ) ; Parameters
sd
- Socket descriptor
bufptr
- Output Parameter: Received data will be put here.
buflen
- Maximum bytes to write to the buffer at
bufptr
.
flags
- Control flags: Either MSG_BLOCKING or MSG_DONTWAIT.
fromPtr
- Output Parameter: Pointer to a
sockaddr_in
(IPv4) or
sockaddr_in6
(IPv6) data structure, which will be set
to indicate from where the received data originated. This pointer
can be set to NULL if this information is not desired.
fromLengthPtr
- Input/Output Parameter: The integer
referenced by this pointer must be set prior to calling to the
length of the object at fromPtr
. If fromPtr
is
NULL, then this parameter is not required and can be set to NULL.
On return the length of object written o fromPtr
will be
reported here.
timeout
- Maximum wait time in milliseconds. Set to
zero to wait forever.
Return Value
- > 0: Number of data bytes placed at bufptr
.
-1: Failure, error code is available using
get_socketerror().
Comments
- This API applies to UDP sockets.
If the waiting datagram at the internal socket receive queue has a size larger
than the specified bufLen
, the return value will be -1 and
error code 240 ("Message too long") will be reported by the
get_socketerror() in this case.
The receive buffer contains the truncated datagram.
This function's prototype takes a pointer to the
generic type sockaddr
for its fromPtr
parameter,for compatibility between IPv4 and IPv6
protocols. The pointer to the sockaddr_in
(IPv4) or
sockaddr_in6
(IPv6) data structure which is actually used
should be cast to a sockaddr
type pointer to avoid compiler
warnings, "Suspicious pointer conversion".
If the compilation switch
#define BSD44_SOCKET_API_STYLE
is set as a global define in the user application prior to including the
Beck C-library header files, the recvfrom()
call can be used in
BSD 4.4 compatible style with the parameters specified above.
Using this switch the CLIB TCPIP_Socket.H redefines recvfrom()
to recvfrom_bsd()
.
See Also
RTOS API
- On the first call, this library function invokes a software
interrupt
which modifies the code at the calling site inside your application
program. A direct FAR JMP into the @CHIP-RTOS-x86
implementation for this function is installed so that on
return and on any subsequent calls to this API this
dynamic link reaches the function's
implementation directly.
Supported since or modified in @CHIP-RTOS version-
| SC12 | SC13 | SC11 | SC1x3 | SC2x |
-
| n/a | n/a | n/a | V1.36 | V1.36 |
Supported by @CHIP-RTOS C Library since version
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|