www.beck-ipc.com

@CHIP-RTOS C Library V2.06 - 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

Output parameter:   Pointer to input buffer where received characters will be stored.

bufLen

Maximum characters to store in buffer at bufptr .

flags

Wait option:
  • MSG_BLOCKING - Sleep until data comes in.
  • MSG_TIMEOUT - The caller wakes up after timeout or if bufLen data is received.
  • 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
otherwise: 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.

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3
    V1.00V1.00V1.00V0.90

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


End of document