|
WSASend transmits a message on a connected socket.
Syntax
int WSASend( __in SOCKET s, __in LPWSABUF lpBuffers, __in DWORD dwBufferCount, __out LPDWORD lpNumberOfBytesSent, __in DWORD dwFlags, __in LPWSAOVERLAPPED lpOverlapped, __in LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
Parameters
s
Socket descriptor identifying connected 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.
lpNumberOfBytesSent
A pointer to the number of bytes sent by this call if the WSASend operation completes.
dwFlags
A set of flags arguments that is logical OR of one or more of the following:
Flag |
Description |
MSG_DONTROUTE |
Send without using routing tables. |
MSG_OOB |
Process urgent data, SOCK_STREAM only. |
MSG_FDBROADCAST* |
Send a full duplex broadcast. This flag causes a broadcast packet to be received by this node also. The default is not to receive your own broadcasts. |
*Included in RtTcpIp.h header file
lpOverlapped
Ignored. A pointer to a WSAOVERLAPPED structure. This parameter is ignored for nonoverlapped sockets.
lpCompletionRoutine
Ignored. A pointer to the completion routine called when the send operation has been completed. This parameter is ignored for nonoverlapped sockets.
Return Values
A positive value if the function succeeds, SOCKET_ERROR if the function fails
Use WSAGetLastError to retrieve a specific error code.
Remarks
If there is insufficient space in the socket send queue to hold all the user data then, for blocking sockets, the send routines will block the calling process until space becomes available. On TCP sockets or on UDP, if there is no space available in the send queue, a value of SOCKET_ERROR is returned and WSAEWOULDBLOCK is the last error set.
The length of the message is indicated by the len parameter. If the message is too long to pass through the underlying protocol and the protocol does not support fragmentation, SOCKET_ERROR is returned and WSAEMSGSIZE is the last error set.
Successful completion of send does not imply successful reception of the message by the target host. For most protocols, a return value of SOCKET_ERROR indicates some locally detected error. Use select function to determine when it is possible to send more data.
Requirements
Library | Rtxtcpip.lib |