WSARecvFrom
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( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags, struct sockaddr *lpFrom, LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped, 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.
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.
lpCompletionRoutine
Ignored.
Return Value
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
Minimum Supported Version | RTX64 2013 |
Header | Winsock2.h |
Library | RtTcpip.lib |