IPC@CHIP® RTOS-PPC – API Documentation

Header image

Main page

int recv_bsd ( int  sd,
char *  bufptr,
int  buflen,
int  flags,
unsigned long  timeout 

This function is used to receive messages from another socket.

If the define switch


is set as a global define at the user application, the recv() call can be used in BSD 4.4 compatible style with the parameters listed below.
Using this switch the CLIB TCPIP.H redefines a call to recv() to recv_bsd() as follows:

 #define recv(sd,bufptr,bufLen,flags)  recv_bsd(sd,bufptr,bufLen,flags,0)

The parameters of recv_bsd() are identical to the parameters of the BSD4.4 socket function recv(), except the timeout parameter.
Parameter timeout is set to zero in the macro above.

[in] sd The socket descriptor
[out] bufptr Pointer to input buffer where received characters will be stored.
[in] buflen Maximum characters to store in buffer at bufptr
[in] flags Wait option:
MSG_BLOCKING - Sleep until data comes in.
MSG_DONTWAIT - Return immediately after collecting what ever data is ready.
Additionally, the MSG_PEEK flag can be bitwise OR'ed in to return without freeing the packet. The data is returned, but not consumed so that a subsequent receive operation will see the same data.
[in] timeout Maximum wait time in milliseconds. Set to zero to wait forever when blocking mode is in effect. This parameter has no effect if the MSG_DONTWAIT flag is set.
>=0: Count of received bytes stored in buffer at bufptr
-1: Failure, a detailed errorcode can be retrieved by get_socketerror().
This API function applies only to TCP sockets and may be used only on a connected socket (see connect(), accept()).

The MSG_BLOCKING mode will not work if the socket has been put into non-blocking mode using the SocketBlockingMode() function, unless the timeout parameter is non-zero.

If flags parameter is set to MSG_BLOCKING and this socket had not been switched to non-blocking mode, the recv_bsd() call waits for either a message to arrive, timeout milliseconds (assuming timeout was non-zero), or a socket error condition to occur (such as connection lost or socket closed). By default the blocking mode is set true at the opensocket() call. The socket may subsequently be set to non-blocking mode with the Set_Blocking_Mode() API. The MSG_DONTWAIT flag set here will override this internal socket state.

If flags parameter is set to MSG_DONTWAIT, this API call returns immediately. If no data is available -1 is returned and output parameter error is set to 235 (EWOULDBLOCK).
SC2x3 V1.00 - CLIB V1.00

Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Jan 26 16:21:38 2017 by Doxygen 1.6.1