Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
basic_stream_socket::send (1 of 3 overloads)

Send some data on the socket.

    typename ConstBufferSequence>
std::size_t send(
    const ConstBufferSequence & buffers);

This function is used to send data on the stream socket. The function call will block until one or more bytes of the data has been sent successfully, or an until error occurs.



One or more data buffers to be sent on the socket.

Return Value

The number of bytes sent.



Thrown on failure.


The send operation may not transmit all of the data to the peer. Consider using the write function if you need to ensure that all data is written before the blocking operation completes.


To send a single data buffer use the buffer function as follows:

socket.send(boost::asio::buffer(data, size));

See the buffer documentation for information on sending multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.