Chris@16: // Chris@16: // write.hpp Chris@16: // ~~~~~~~~~ Chris@16: // Chris@101: // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASIO_WRITE_HPP Chris@16: #define BOOST_ASIO_WRITE_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace asio { Chris@16: Chris@16: /** Chris@16: * @defgroup write boost::asio::write Chris@16: * Chris@16: * @brief Write a certain amount of data to a stream before returning. Chris@16: */ Chris@16: /*@{*/ Chris@16: Chris@16: /// Write all of the supplied data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to write to the Chris@16: * stream. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @par Example Chris@16: * To write a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::write(s, boost::asio::buffer(data, size)); @endcode Chris@16: * See the @ref buffer documentation for information on writing multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::write( Chris@16: * s, buffers, Chris@16: * boost::asio::transfer_all()); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers); Chris@16: Chris@16: /// Write all of the supplied data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to write to the Chris@16: * stream. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @par Example Chris@16: * To write a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::write(s, boost::asio::buffer(data, size), ec); @endcode Chris@16: * See the @ref buffer documentation for information on writing multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::write( Chris@16: * s, buffers, Chris@16: * boost::asio::transfer_all(), ec); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: /// Write a certain amount of data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to write to the Chris@16: * stream. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's write_some function. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @par Example Chris@16: * To write a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::write(s, boost::asio::buffer(data, size), Chris@16: * boost::asio::transfer_at_least(32)); @endcode Chris@16: * See the @ref buffer documentation for information on writing multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers, Chris@16: CompletionCondition completion_condition); Chris@16: Chris@16: /// Write a certain amount of data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. The sum Chris@16: * of the buffer sizes indicates the maximum number of bytes to write to the Chris@16: * stream. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's write_some function. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes written. If an error occurs, returns the total Chris@16: * number of bytes successfully transferred prior to the error. Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers, Chris@16: CompletionCondition completion_condition, boost::system::error_code& ec); Chris@16: Chris@16: #if !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /// Write all of the supplied data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param b The basic_streambuf object from which data will be written. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::write( Chris@16: * s, b, Chris@16: * boost::asio::transfer_all()); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, basic_streambuf& b); Chris@16: Chris@16: /// Write all of the supplied data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param b The basic_streambuf object from which data will be written. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @note This overload is equivalent to calling: Chris@16: * @code boost::asio::write( Chris@16: * s, b, Chris@16: * boost::asio::transfer_all(), ec); @endcode Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, basic_streambuf& b, Chris@16: boost::system::error_code& ec); Chris@16: Chris@16: /// Write a certain amount of data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param b The basic_streambuf object from which data will be written. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's write_some function. Chris@16: * Chris@16: * @returns The number of bytes transferred. Chris@16: * Chris@16: * @throws boost::system::system_error Thrown on failure. Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, basic_streambuf& b, Chris@16: CompletionCondition completion_condition); Chris@16: Chris@16: /// Write a certain amount of data to a stream before returning. Chris@16: /** Chris@16: * This function is used to write a certain number of bytes of data to a stream. Chris@16: * The call will block until one of the following conditions is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * write_some function. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the SyncWriteStream concept. Chris@16: * Chris@16: * @param b The basic_streambuf object from which data will be written. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's write_some function. Chris@16: * Chris@16: * @param ec Set to indicate what error occurred, if any. Chris@16: * Chris@16: * @returns The number of bytes written. If an error occurs, returns the total Chris@16: * number of bytes successfully transferred prior to the error. Chris@16: */ Chris@16: template Chris@16: std::size_t write(SyncWriteStream& s, basic_streambuf& b, Chris@16: CompletionCondition completion_condition, boost::system::error_code& ec); Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /*@}*/ Chris@16: /** Chris@16: * @defgroup async_write boost::asio::async_write Chris@16: * Chris@16: * @brief Start an asynchronous operation to write a certain amount of data to a Chris@16: * stream. Chris@16: */ Chris@16: /*@{*/ Chris@16: Chris@16: /// Start an asynchronous operation to write all of the supplied data to a Chris@16: /// stream. Chris@16: /** Chris@16: * This function is used to asynchronously write a certain number of bytes of Chris@16: * data to a stream. The function call always returns immediately. The Chris@16: * asynchronous operation will continue until one of the following conditions Chris@16: * is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * async_write_some function, and is known as a composed operation. The Chris@16: * program must ensure that the stream performs no other write operations (such Chris@16: * as async_write, the stream's async_write_some function, or any other composed Chris@16: * operations that perform writes) until this operation completes. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the AsyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. Chris@16: * Although the buffers object may be copied as necessary, ownership of the Chris@16: * underlying memory blocks is retained by the caller, which must guarantee Chris@16: * that they remain valid until the handler is called. Chris@16: * Chris@16: * @param handler The handler to be called when the write operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of Chris@16: * the handler must be: Chris@16: * @code void handler( Chris@16: * const boost::system::error_code& error, // Result of operation. Chris@16: * Chris@16: * std::size_t bytes_transferred // Number of bytes written from the Chris@16: * // buffers. If an error occurred, Chris@16: * // this will be less than the sum Chris@16: * // of the buffer sizes. Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: * Chris@16: * @par Example Chris@16: * To write a single data buffer use the @ref buffer function as follows: Chris@16: * @code Chris@16: * boost::asio::async_write(s, boost::asio::buffer(data, size), handler); Chris@16: * @endcode Chris@16: * See the @ref buffer documentation for information on writing multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, Chris@16: BOOST_ASIO_MOVE_ARG(WriteHandler) handler); Chris@16: Chris@16: /// Start an asynchronous operation to write a certain amount of data to a Chris@16: /// stream. Chris@16: /** Chris@16: * This function is used to asynchronously write a certain number of bytes of Chris@16: * data to a stream. The function call always returns immediately. The Chris@16: * asynchronous operation will continue until one of the following conditions Chris@16: * is true: Chris@16: * Chris@16: * @li All of the data in the supplied buffers has been written. That is, the Chris@16: * bytes transferred is equal to the sum of the buffer sizes. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * async_write_some function, and is known as a composed operation. The Chris@16: * program must ensure that the stream performs no other write operations (such Chris@16: * as async_write, the stream's async_write_some function, or any other composed Chris@16: * operations that perform writes) until this operation completes. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the AsyncWriteStream concept. Chris@16: * Chris@16: * @param buffers One or more buffers containing the data to be written. Chris@16: * Although the buffers object may be copied as necessary, ownership of the Chris@16: * underlying memory blocks is retained by the caller, which must guarantee Chris@16: * that they remain valid until the handler is called. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest async_write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's async_write_some function. Chris@16: * Chris@16: * @param handler The handler to be called when the write operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * const boost::system::error_code& error, // Result of operation. Chris@16: * Chris@16: * std::size_t bytes_transferred // Number of bytes written from the Chris@16: * // buffers. If an error occurred, Chris@16: * // this will be less than the sum Chris@16: * // of the buffer sizes. Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: * Chris@16: * @par Example Chris@16: * To write a single data buffer use the @ref buffer function as follows: Chris@16: * @code boost::asio::async_write(s, Chris@16: * boost::asio::buffer(data, size), Chris@16: * boost::asio::transfer_at_least(32), Chris@16: * handler); @endcode Chris@16: * See the @ref buffer documentation for information on writing multiple Chris@16: * buffers in one go, and how to use it with arrays, boost::array or Chris@16: * std::vector. Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, Chris@16: CompletionCondition completion_condition, Chris@16: BOOST_ASIO_MOVE_ARG(WriteHandler) handler); Chris@16: Chris@16: #if !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /// Start an asynchronous operation to write all of the supplied data to a Chris@16: /// stream. Chris@16: /** Chris@16: * This function is used to asynchronously write a certain number of bytes of Chris@16: * data to a stream. The function call always returns immediately. The Chris@16: * asynchronous operation will continue until one of the following conditions Chris@16: * is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li An error occurred. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * async_write_some function, and is known as a composed operation. The Chris@16: * program must ensure that the stream performs no other write operations (such Chris@16: * as async_write, the stream's async_write_some function, or any other composed Chris@16: * operations that perform writes) until this operation completes. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the AsyncWriteStream concept. Chris@16: * Chris@16: * @param b A basic_streambuf object from which data will be written. Ownership Chris@16: * of the streambuf is retained by the caller, which must guarantee that it Chris@16: * remains valid until the handler is called. Chris@16: * Chris@16: * @param handler The handler to be called when the write operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * const boost::system::error_code& error, // Result of operation. Chris@16: * Chris@16: * std::size_t bytes_transferred // Number of bytes written from the Chris@16: * // buffers. If an error occurred, Chris@16: * // this will be less than the sum Chris@16: * // of the buffer sizes. Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_write(AsyncWriteStream& s, basic_streambuf& b, Chris@16: BOOST_ASIO_MOVE_ARG(WriteHandler) handler); Chris@16: Chris@16: /// Start an asynchronous operation to write a certain amount of data to a Chris@16: /// stream. Chris@16: /** Chris@16: * This function is used to asynchronously write a certain number of bytes of Chris@16: * data to a stream. The function call always returns immediately. The Chris@16: * asynchronous operation will continue until one of the following conditions Chris@16: * is true: Chris@16: * Chris@16: * @li All of the data in the supplied basic_streambuf has been written. Chris@16: * Chris@16: * @li The completion_condition function object returns 0. Chris@16: * Chris@16: * This operation is implemented in terms of zero or more calls to the stream's Chris@16: * async_write_some function, and is known as a composed operation. The Chris@16: * program must ensure that the stream performs no other write operations (such Chris@16: * as async_write, the stream's async_write_some function, or any other composed Chris@16: * operations that perform writes) until this operation completes. Chris@16: * Chris@16: * @param s The stream to which the data is to be written. The type must support Chris@16: * the AsyncWriteStream concept. Chris@16: * Chris@16: * @param b A basic_streambuf object from which data will be written. Ownership Chris@16: * of the streambuf is retained by the caller, which must guarantee that it Chris@16: * remains valid until the handler is called. Chris@16: * Chris@16: * @param completion_condition The function object to be called to determine Chris@16: * whether the write operation is complete. The signature of the function object Chris@16: * must be: Chris@16: * @code std::size_t completion_condition( Chris@16: * // Result of latest async_write_some operation. Chris@16: * const boost::system::error_code& error, Chris@16: * Chris@16: * // Number of bytes transferred so far. Chris@16: * std::size_t bytes_transferred Chris@16: * ); @endcode Chris@16: * A return value of 0 indicates that the write operation is complete. A Chris@16: * non-zero return value indicates the maximum number of bytes to be written on Chris@16: * the next call to the stream's async_write_some function. Chris@16: * Chris@16: * @param handler The handler to be called when the write operation completes. Chris@16: * Copies will be made of the handler as required. The function signature of the Chris@16: * handler must be: Chris@16: * @code void handler( Chris@16: * const boost::system::error_code& error, // Result of operation. Chris@16: * Chris@16: * std::size_t bytes_transferred // Number of bytes written from the Chris@16: * // buffers. If an error occurred, Chris@16: * // this will be less than the sum Chris@16: * // of the buffer sizes. Chris@16: * ); @endcode Chris@16: * Regardless of whether the asynchronous operation completes immediately or Chris@16: * not, the handler will not be invoked from within this function. Invocation of Chris@16: * the handler will be performed in a manner equivalent to using Chris@16: * boost::asio::io_service::post(). Chris@16: */ Chris@16: template Chris@16: BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, Chris@16: void (boost::system::error_code, std::size_t)) Chris@16: async_write(AsyncWriteStream& s, basic_streambuf& b, Chris@16: CompletionCondition completion_condition, Chris@16: BOOST_ASIO_MOVE_ARG(WriteHandler) handler); Chris@16: Chris@16: #endif // !defined(BOOST_ASIO_NO_IOSTREAM) Chris@16: Chris@16: /*@}*/ Chris@16: Chris@16: } // namespace asio Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_ASIO_WRITE_HPP