www.beck-ipc.com

@CHIP-RTOS C Library V2.00 - TCP/IP API


recv

Receive a message from another socket.

int recv ( int sd, char far *bufptr, int bufLen,
           int flags, unsigned long timeout,
           int *error );

Parameters

sd

Socket descriptor.

bufptr

Pointer to input buffer where received characters will be stored.

bufLen

Maximum characters to store in buffer at bufptr .

flags

Wait options:
  MSG_BLOCKING - Sleep until data comes in
  MSG_TIMEOUT - The caller wakes up after timeout or if bufLen data comes in
  MSG_DONTWAIT - Return immediately after collecting what ever data is ready

timeout

Maximum milliseconds to wait if flags is set to MSG_TIMEOUT:

error

Output parameter:  Failure code, 0 on success.

Return Value

-1: Failure, see error value reported
else count of received bytes stored in buffer at bufptr .

Comments

This API function applies only to TCP sockets.   It receives a message from another socket.   This API function may be used only if the socket is in a connected 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.

If flags parameter is set to MSG_BLOCKING, the recv call waits for a message to arrive.   By default the blocking mode is set for all sockets at the opensocket call.   If however a socket was subsequently set to non blocking mode with the Set_Blocking_Mode API, the MSG_BLOCKING flag will then not work here.

See Also

RTOS API

This library function invokes a RTOS software interrupt. Refer to this RTOS API function's documentation for more details.


This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document