CAsyncSocket::Send

virtual int Send( const void* lpBuf, int nBufLen, int nFlags = 0 );

Return Value

If no error occurs, Send returns the total number of characters sent. (Note that this can be less than the number indicated by nBufLen.) Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling GetLastError. The following errors apply to this member function:

Parameters

lpBuf

A buffer containing the data to be transmitted.

nBufLen

The length of the data in lpBuf in bytes.

nFlags

Specifies the way in which the call is made. The semantics of this function are determined by the socket options and the nFlags parameter. The latter is constructed by combining any of the following values with the C++ OR operator:

Remarks

Call this member function to send data on a connected socket. Send is used to write outgoing data on connected stream or datagram sockets. For datagram sockets, care must be taken not to exceed the maximum IP packet size of the underlying subnets, which is given by the iMaxUdpDg element in the WSADATA structure returned by AfxSocketInit. If the data is too long to pass atomically through the underlying protocol, the error WSAEMSGSIZE is returned via GetLastError, and no data is transmitted.

Note that for a datagram socket the successful completion of a Send does not indicate that the data was successfully delivered.

On CAsyncSocket objects of type SOCK_STREAM, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both the local and foreign hosts.

CAsyncSocket OverviewClass MembersHierarchy Chart

See Also   CAsyncSocket::Create, CAsyncSocket::Receive, CAsyncSocket::ReceiveFrom, CAsyncSocket::SendTo