WSASend

WSASend transmits a message on a connected socket.

Syntax

int WSASend(
    SOCKET s,
    LPWSABUF lpBuffers,
    DWORD dwBufferCount,
    LPDWORD lpNumberOfBytesSent,
    DWORD dwFlags,
    LPWSAOVERLAPPED lpOverlapped,
    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.

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.

lpOverlapped

Ignored.

lpCompletionRoutine

Ignored.

Return Value

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. If the socket is in non-blocking I/O mode or the MSG_NONBLOCKING flag is set, then the send routines will take as much of the data as will fit, on a TCP socket, and return the amount taken. 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

Minimum Supported Version RTX64 2013
Header Winsock2.h
Library RtTcpip.lib