|
send transmits a message on a connected socket.
Syntax
int send( __in SOCKET s, __in const char *buf, __in int len, __in int flags );
Parameters
s
Socket descriptor identifying connected socket.
buf
Pointer to a character buffer that holds the data to send.
len
An integer that defines the size in bytes of buf.
flags
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
Return Values
The number of bytes sent 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.