|
WSARecvFrom receives a datagram on a socket and returns the number of bytes received. If the data is too long to fit in the supplied buffer, excess bytes may be discarded, depending on the type of socket on which data is received.
Syntax
int WSARecvFrom( __in SOCKET s, __inout LPWSABUF lpBuffers, __in DWORD dwBufferCount, __out LPDWORD lpNumberOfBytesRecvd, __inout LPDWORD lpFlags, __out struct sockaddr *lpFrom, __inout LPINT lpFromlen, __in LPWSAOVERLAPPED lpOverlapped, __in LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
Parameters
s
Socket descriptor identifying bound socket.
lpBuffers
A pointer to a WSABUF structure. The WSABUF structure contains a pointer to a buffer and the length, in bytes, of the buffer.
dwBufferCount
Ignored. The number of WSABUF structures in the lpBuffers array.
lpNumberOfBytesRecvd
A pointer to the number of bytes received by this call if the WSARecvFrom operation completes immediately.
lpFlags
Receive flags. Refer to WSARecv for possible values
lpFrom
If lpFrom is nonzero, the source address of the received packet is filled in. On a UDP or TCP socket, the application MUST pass in the address of a sockaddr structure.
lpFromlen
Initialized to the size of the address structure associated with lpFrom. Upon return, lpFromlen is modified to indicate the actual size of the address stored in lpFrom.
lpOverlapped
Ignored. A pointer to a WSAOVERLAPPED structure (ignored for nonoverlapped sockets).
lpCompletionRoutine
Ignored. A pointer to the completion routine called when the WSARecvFrom operation has been completed (ignored for nonoverlapped sockets).
Return Values
A positive value if the function succeeds, SOCKET_EROR if the function fails
Use WSAGetLastError to retrieve a specific error code.
Remarks
On a raw socket, the count of bytes includes all protocol headers encapsulated within the header of the raw socket. For example, on a raw Ethernet socket, if a UDP datagram is received, then the count of bytes includes the IP and UDP headers as well as user data.
Requirements
Library | Rtxtcpip.lib |