Function SocketRecvFrom() Professional

Receives a datagram and stores the sender's address.

Syntax
SocketRecvFrom( <nSocket>     , ;
                @<cBuffer>    , ;
                [<nLength>]   , ;
                [<nFlag>]     , ;
                [@<aFromAddr>], ;
                [@<nError>]     ) --> nBytesWritten
Parameters
<nSocket>
This is a numeric socket descriptor identifying a bound but unconnected socket.
<cBuffer>
A character string serving as buffer for the incoming data must be passed by reference.
<nLength>
Optionally, the number of bytes to read can be specified. This parameter defaults to Len(<cBuffer>).
<nFlag>
#define constants from the file SOCKET.CH are used for this parameter. It specifies the way in which the call is made.
Constants for data retrieval
Constant Description
MSG_NORMAL *) Copy incoming data to <cBuffer> and remove copied data from the input queue.
MSG_PEEK Copy incoming data to <cBuffer> and leave the data in the input queue.
MSG_OOB Process out-of-band data.
  1. default
<aFromAddr>
If passed by reference, an array containing IP address information of the sender of the datagram is assigned to <aFromAddr>. The following #define constants are available in the file SOCKET.CH to access the individual array elements:
Constants for the IP address array
Constant Description
IPADDR_ADDR Numeric IP address in network byte order.
IPADDR_FAMILY Address family (Windows sockets support only AF_INET).
IPADDR_PORT Number of port the socket is associated with.
<nError>
If this parameter is passed by reference to the function, it gets assigned a numeric error code when the function fails. #define constants beginning with WSAE are available in the file SOCKET.CH to identify an error condition.
Return

Returns the number of bytes read from the input queue or 0 in case of a failure.

Description

This function is typically used to receive datagrams on unconnected sockets. However, the function can be called on any datagram socket, be it connected or unconnected. SocketRecvFrom() copies incoming data into a buffer and may be used to obtain a datagram sender's address data. The number of bytes read from the input queue is returned. When a datagram is received that is too long to fit into the buffer, excess data is discarded. If no datagram is available, the function blocks waiting for a message to arrive, unless the socket is in nonblocking mode.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.