send

This function sends data on a connected socket.

int send (
SOCKET s, 
const char *buf, 
int len, 
int flags ); 

Parameters

  • s
    [in] Descriptor that identifies a connected socket.
  • buf
    [in] Buffer containing the data to be transmitted.
  • len
    [in] Length of the data in buf.
  • flags
    [in] Specifies the way in which the call is made.

Return Values

The total number of bytes sent, which can be less than the number indicated by len for nonblocking sockets, indicates that no errors occurred. SOCKET_ERROR indicates failure. To get a specific error value, call WSAGetLastError.

Remarks

For Infrared Sockets (IrSock), the Af_irda.h file must be explicitly included.

The send function is used to write outgoing data on a connected socket. For message-oriented sockets, care must be taken not to exceed the maximum packet size of the underlying provider. If the data is too long to pass atomically through the underlying protocol, the error WSAEMSGSIZE is returned, and no data is transmitted.

The successful completion of a send does not indicate that the data was successfully delivered.

If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in a nonblocking mode. On nonblocking stream oriented sockets, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both client and server machines. The select function can be used to determine when it is possible to send more data.

Calling send with a zero len parameter is permissible and will be treated by implementations as successful. In such cases, send will return zero as a valid value. For message-oriented sockets, a zero-length transport datagram is sent.

The flags parameter is used to influence the behavior of the function beyond the options specified for the associated socket. However, Windows CE silently ignores the MSG_DONTROUTE value and does not support MSG_OOB.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winsock.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

bind, recv, recvfrom, socket, select, sendto, shutdown, WSAStartup

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.