recv Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
recv Function
C
int recv(
    SOCKET s, 
    char* buf, 
    int len, 
    int flags
);
Description

The recv() function is used to receive incoming data that has been queued for a socket. This function can be used with both datagram and stream socket. If the available data is too large to fit in the supplied application buffer buf, excess bytes are discarded in case of SOCK_DGRAM type sockets. For SOCK_STREAM types, the data is buffered internally so the application can retreive all data by multiple calls of recvfrom.

Preconditions

connect function should be called for TCP and UDP sockets. Server side, accept function should be called.

Parameters
Parameters 
Description 
Socket descriptor returned from a previous call to socket. 
buf 
application data receive buffer. 
len 
buffer length in bytes. 
flags 
no significance in this implementation 
Returns

If recv is successful, the number of bytes copied to application buffer buf is returned. A value of zero indicates no data available. A return value of SOCKET_ERROR (-1) indicates an error condition. A return value of SOCKET_DISCONNECTED indicates the connection no longer exists.

Remarks

None.

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.