Internet Direct (Indy)
|
Receives a datagram and stores the origin address.
function RecvFrom( const ASocket: TIdStackSocketHandle; var VBuffer; const ALength: Integer; const AFlags: Integer; var VIP: string; var VPort: Integer; AIPVersion: TIdIPVersion = ID_DEFAULT_IP_VERSION ): Integer; override;
Parameters |
Description |
ASocket |
Socket handle for the read operation. |
ALength |
Sized of the buffer. |
AFlags |
Flags for the RecvFrom() API. |
VIP |
IP address for the remote network sending the data. |
VPort |
Port number for the remote network sending the data. |
AIPVersion |
IP version for the connection. Default is ID_DEFAULT_IP_VERSION. |
ABuffer |
Stores values read from the sockt handle. |
Integer - Number of bytes read from the socket handle and remote destination.
RecvFrom is an overridden Integer function that implements the interface used to access the RecvFrom() API for the protocol stack implementation.
RecvFrom provides access to low-level options and flags not available in ReceiveFrom.
RecvFrom is used to receive a datagram and to store the origin address in VIP and VPort. RecvFrom reads incoming data on both connected and unconnected socket handles.
For stream-oriented sockets such as those of type SOCK_STREAM, a call to recvfrom returns as much information as is currently available—up to the size of the buffer specified.
If the socket has been configured for inline reception of OOB data (socket option SO_OOBINLINE) and OOB data is yet unread, only OOB data will be returned. The application can use the ioctlsocket or WSAIoctl SIOCATMARK command to determine whether any more OOB data remains to be read. The from and fromlen parameters are ignored for connection-oriented sockets.
For message-oriented sockets, data is extracted from the first enqueued message, up to the size of the buffer specified. If the datagram or message is larger than the buffer specified, the buffer is filled with the first part of the datagram, and recvfrom generates the error WSAEMSGSIZE. For unreliable protocols (for example, UDP) the excess data is lost.
If the from parameter is nonzero and the socket is not connection oriented, (type SOCK_DGRAM for example), the network address of the peer that sent the data is copied to the corresponding sockaddr structure. The value pointed to by fromlen is initialized to the size of this structure and is modified, on return, to indicate the actual size of the address stored in the sockaddr structure.
If no incoming data is available at the socket, the recvfrom function blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect can be used to determine when more data arrives.
If the socket is connection oriented and the remote side has shut down the connection gracefully, the call to recvfrom will complete immediately with zero bytes received. If the connection has been reset recvfrom will fail with the error WSAECONNRESET.
The flags parameter can be used to influence the behavior of the function invocation beyond the options specified for the associated socket. The semantics of this function are determined by the socket options and the flags parameter. The latter is constructed by using the bitwise OR operator with any of the following values.
Value |
Meaning |
MSG_PEEK |
Peeks at the incoming data. The data is copied into the buffer but is not removed from the input queue. The function subsequently returns the amount of data that can be read in a single call to the recvfrom (or recv) function, which may not be the same as the total amount of data queued on the socket. The amount of data that can actually be read in a single call to the recvfrom (or recv) function is limited to the data size written in the send or sendto function call. |
MSG_OOB |
Processes OOB data. |
Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved. Website http://www.indyproject.org. Post feedback to the Indy Documentation newsgroup. |