Update of /cvsroot/boost/boost/boost/asio/ssl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17073/boost/asio/ssl
Modified Files:
basic_context.hpp context_service.hpp stream.hpp
stream_service.hpp
Log Message:
Change error handling to match TR2 proposal.
Index: basic_context.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/ssl/basic_context.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- basic_context.hpp 4 Nov 2006 07:14:09 -0000 1.2
+++ basic_context.hpp 8 Nov 2006 05:32:12 -0000 1.3
@@ -23,9 +23,10 @@
#include <boost/noncopyable.hpp>
#include <boost/asio/detail/pop_options.hpp>
-#include <boost/asio/error_handler.hpp>
+#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ssl/context_base.hpp>
+#include <boost/asio/detail/throw_error.hpp>
namespace boost {
namespace asio {
@@ -77,11 +78,13 @@
* the context_base class. The options are bitwise-ored with any existing
* value for the options.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void set_options(options o)
{
- service_.set_options(impl_, o, throw_error());
+ boost::system::error_code ec;
+ service_.set_options(impl_, o, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Set options on the context.
@@ -92,17 +95,12 @@
* the context_base class. The options are bitwise-ored with any existing
* value for the options.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void set_options(options o, Error_Handler error_handler)
+ boost::system::error_code set_options(options o,
+ boost::system::error_code& ec)
{
- service_.set_options(impl_, o, error_handler);
+ return service_.set_options(impl_, o, ec);
}
/// Set the peer verification mode.
@@ -113,11 +111,13 @@
* @param v A bitmask of peer verification modes. The available verify_mode
* values are defined in the context_base class.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void set_verify_mode(verify_mode v)
{
- service_.set_verify_mode(impl_, v, throw_error());
+ boost::system::error_code ec;
+ service_.set_verify_mode(impl_, v, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Set the peer verification mode.
@@ -128,17 +128,12 @@
* @param v A bitmask of peer verification modes. The available verify_mode
* values are defined in the context_base class.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void set_verify_mode(verify_mode v, Error_Handler error_handler)
+ boost::system::error_code set_verify_mode(verify_mode v,
+ boost::system::error_code& ec)
{
- service_.set_verify_mode(impl_, v, error_handler);
+ return service_.set_verify_mode(impl_, v, ec);
}
/// Load a certification authority file for performing verification.
@@ -149,11 +144,13 @@
* @param filename The name of a file containing certification authority
* certificates in PEM format.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void load_verify_file(const std::string& filename)
{
- service_.load_verify_file(impl_, filename, throw_error());
+ boost::system::error_code ec;
+ service_.load_verify_file(impl_, filename, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Load a certification authority file for performing verification.
@@ -164,18 +161,12 @@
* @param filename The name of a file containing certification authority
* certificates in PEM format.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void load_verify_file(const std::string& filename,
- Error_Handler error_handler)
+ boost::system::error_code load_verify_file(const std::string& filename,
+ boost::system::error_code& ec)
{
- service_.load_verify_file(impl_, filename, error_handler);
+ return service_.load_verify_file(impl_, filename, ec);
}
/// Add a directory containing certificate authority files to be used for
@@ -188,11 +179,13 @@
*
* @param path The name of a directory containing the certificates.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void add_verify_path(const std::string& path)
{
- service_.add_verify_path(impl_, path, throw_error());
+ boost::system::error_code ec;
+ service_.add_verify_path(impl_, path, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Add a directory containing certificate authority files to be used for
@@ -205,17 +198,12 @@
*
* @param path The name of a directory containing the certificates.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void add_verify_path(const std::string& path, Error_Handler error_handler)
+ boost::system::error_code add_verify_path(const std::string& path,
+ boost::system::error_code& ec)
{
- service_.add_verify_path(impl_, path, error_handler);
+ return service_.add_verify_path(impl_, path, ec);
}
/// Use a certificate from a file.
@@ -226,11 +214,13 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void use_certificate_file(const std::string& filename, file_format format)
{
- service_.use_certificate_file(impl_, filename, format, throw_error());
+ boost::system::error_code ec;
+ service_.use_certificate_file(impl_, filename, format, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Use a certificate from a file.
@@ -241,18 +231,12 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void use_certificate_file(const std::string& filename, file_format format,
- Error_Handler error_handler)
+ boost::system::error_code use_certificate_file(const std::string& filename,
+ file_format format, boost::system::error_code& ec)
{
- service_.use_certificate_file(impl_, filename, format, error_handler);
+ return service_.use_certificate_file(impl_, filename, format, ec);
}
/// Use a certificate chain from a file.
@@ -263,11 +247,13 @@
* @param filename The name of the file containing the certificate. The file
* must use the PEM format.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void use_certificate_chain_file(const std::string& filename)
{
- service_.use_certificate_chain_file(impl_, filename, throw_error());
+ boost::system::error_code ec;
+ service_.use_certificate_chain_file(impl_, filename, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Use a certificate chain from a file.
@@ -278,18 +264,12 @@
* @param filename The name of the file containing the certificate. The file
* must use the PEM format.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void use_certificate_chain_file(const std::string& filename,
- Error_Handler error_handler)
+ boost::system::error_code use_certificate_chain_file(
+ const std::string& filename, boost::system::error_code& ec)
{
- service_.use_certificate_chain_file(impl_, filename, error_handler);
+ return service_.use_certificate_chain_file(impl_, filename, ec);
}
/// Use a private key from a file.
@@ -300,11 +280,13 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void use_private_key_file(const std::string& filename, file_format format)
{
- service_.use_private_key_file(impl_, filename, format, throw_error());
+ boost::system::error_code ec;
+ service_.use_private_key_file(impl_, filename, format, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Use a private key from a file.
@@ -315,18 +297,12 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void use_private_key_file(const std::string& filename, file_format format,
- Error_Handler error_handler)
+ boost::system::error_code use_private_key_file(const std::string& filename,
+ file_format format, boost::system::error_code& ec)
{
- service_.use_private_key_file(impl_, filename, format, error_handler);
+ return service_.use_private_key_file(impl_, filename, format, ec);
}
/// Use an RSA private key from a file.
@@ -338,11 +314,13 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void use_rsa_private_key_file(const std::string& filename, file_format
format)
{
- service_.use_rsa_private_key_file(impl_, filename, format, throw_error());
+ boost::system::error_code ec;
+ service_.use_rsa_private_key_file(impl_, filename, format, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Use an RSA private key from a file.
@@ -354,18 +332,13 @@
*
* @param format The file format (ASN.1 or PEM).
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void use_rsa_private_key_file(const std::string& filename, file_format
format,
- Error_Handler error_handler)
+ boost::system::error_code use_rsa_private_key_file(
+ const std::string& filename, file_format format,
+ boost::system::error_code& ec)
{
- service_.use_rsa_private_key_file(impl_, filename, format, error_handler);
+ return service_.use_rsa_private_key_file(impl_, filename, format, ec);
}
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
@@ -376,11 +349,13 @@
* @param filename The name of the file containing the Diffie-Hellman
* parameters. The file must use the PEM format.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void use_tmp_dh_file(const std::string& filename)
{
- service_.use_tmp_dh_file(impl_, filename, throw_error());
+ boost::system::error_code ec;
+ service_.use_tmp_dh_file(impl_, filename, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
@@ -391,17 +366,12 @@
* @param filename The name of the file containing the Diffie-Hellman
* parameters. The file must use the PEM format.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void use_tmp_dh_file(const std::string& filename, Error_Handler
error_handler)
+ boost::system::error_code use_tmp_dh_file(const std::string& filename,
+ boost::system::error_code& ec)
{
- service_.use_tmp_dh_file(impl_, filename, error_handler);
+ return service_.use_tmp_dh_file(impl_, filename, ec);
}
/// Set the password callback.
@@ -417,12 +387,14 @@
* ); @endcode
* The return value of the callback is a string containing the password.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
template <typename Password_Callback>
void set_password_callback(Password_Callback callback)
{
- service_.set_password_callback(impl_, callback, throw_error());
+ boost::system::error_code ec;
+ service_.set_password_callback(impl_, callback, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Set the password callback.
@@ -438,18 +410,13 @@
* ); @endcode
* The return value of the callback is a string containing the password.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Password_Callback, typename Error_Handler>
- void set_password_callback(Password_Callback callback,
- Error_Handler error_handler)
+ template <typename Password_Callback>
+ boost::system::error_code set_password_callback(Password_Callback callback,
+ boost::system::error_code& ec)
{
- service_.set_password_callback(impl_, callback, error_handler);
+ return service_.set_password_callback(impl_, callback, ec);
}
private:
Index: context_service.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/ssl/context_service.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- context_service.hpp 4 Nov 2006 07:14:09 -0000 1.2
+++ context_service.hpp 8 Nov 2006 05:32:12 -0000 1.3
@@ -23,6 +23,7 @@
#include <boost/noncopyable.hpp>
#include <boost/asio/detail/pop_options.hpp>
+#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ssl/context_base.hpp>
#include <boost/asio/ssl/detail/openssl_context_service.hpp>
@@ -78,85 +79,78 @@
}
/// Set options on the context.
- template <typename Error_Handler>
- void set_options(impl_type& impl, context_base::options o,
- Error_Handler error_handler)
+ boost::system::error_code set_options(impl_type& impl,
+ context_base::options o, boost::system::error_code& ec)
{
- service_impl_.set_options(impl, o, error_handler);
+ return service_impl_.set_options(impl, o, ec);
}
/// Set peer verification mode.
- template <typename Error_Handler>
- void set_verify_mode(impl_type& impl, context_base::verify_mode v,
- Error_Handler error_handler)
+ boost::system::error_code set_verify_mode(impl_type& impl,
+ context_base::verify_mode v, boost::system::error_code& ec)
{
- service_impl_.set_verify_mode(impl, v, error_handler);
+ return service_impl_.set_verify_mode(impl, v, ec);
}
/// Load a certification authority file for performing verification.
- template <typename Error_Handler>
- void load_verify_file(impl_type& impl, const std::string& filename,
- Error_Handler error_handler)
+ boost::system::error_code load_verify_file(impl_type& impl,
+ const std::string& filename, boost::system::error_code& ec)
{
- service_impl_.load_verify_file(impl, filename, error_handler);
+ return service_impl_.load_verify_file(impl, filename, ec);
}
/// Add a directory containing certification authority files to be used for
/// performing verification.
- template <typename Error_Handler>
- void add_verify_path(impl_type& impl, const std::string& path,
- Error_Handler error_handler)
+ boost::system::error_code add_verify_path(impl_type& impl,
+ const std::string& path, boost::system::error_code& ec)
{
- service_impl_.add_verify_path(impl, path, error_handler);
+ return service_impl_.add_verify_path(impl, path, ec);
}
/// Use a certificate from a file.
- template <typename Error_Handler>
- void use_certificate_file(impl_type& impl, const std::string& filename,
- context_base::file_format format, Error_Handler error_handler)
+ boost::system::error_code use_certificate_file(impl_type& impl,
+ const std::string& filename, context_base::file_format format,
+ boost::system::error_code& ec)
{
- service_impl_.use_certificate_file(impl, filename, format, error_handler);
+ return service_impl_.use_certificate_file(impl, filename, format, ec);
}
/// Use a certificate chain from a file.
- template <typename Error_Handler>
- void use_certificate_chain_file(impl_type& impl, const std::string& filename,
- Error_Handler error_handler)
+ boost::system::error_code use_certificate_chain_file(impl_type& impl,
+ const std::string& filename, boost::system::error_code& ec)
{
- service_impl_.use_certificate_chain_file(impl, filename, error_handler);
+ return service_impl_.use_certificate_chain_file(impl, filename, ec);
}
/// Use a private key from a file.
- template <typename Error_Handler>
- void use_private_key_file(impl_type& impl, const std::string& filename,
- context_base::file_format format, Error_Handler error_handler)
+ boost::system::error_code use_private_key_file(impl_type& impl,
+ const std::string& filename, context_base::file_format format,
+ boost::system::error_code& ec)
{
- service_impl_.use_private_key_file(impl, filename, format, error_handler);
+ return service_impl_.use_private_key_file(impl, filename, format, ec);
}
/// Use an RSA private key from a file.
- template <typename Error_Handler>
- void use_rsa_private_key_file(impl_type& impl, const std::string& filename,
- context_base::file_format format, Error_Handler error_handler)
+ boost::system::error_code use_rsa_private_key_file(impl_type& impl,
+ const std::string& filename, context_base::file_format format,
+ boost::system::error_code& ec)
{
- service_impl_.use_rsa_private_key_file(impl, filename, format,
- error_handler);
+ return service_impl_.use_rsa_private_key_file(impl, filename, format, ec);
}
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
- template <typename Error_Handler>
- void use_tmp_dh_file(impl_type& impl, const std::string& filename,
- Error_Handler error_handler)
+ boost::system::error_code use_tmp_dh_file(impl_type& impl,
+ const std::string& filename, boost::system::error_code& ec)
{
- service_impl_.use_tmp_dh_file(impl, filename, error_handler);
+ return service_impl_.use_tmp_dh_file(impl, filename, ec);
}
/// Set the password callback.
- template <typename Password_Callback, typename Error_Handler>
- void set_password_callback(impl_type& impl, Password_Callback callback,
- Error_Handler error_handler)
+ template <typename Password_Callback>
+ boost::system::error_code set_password_callback(impl_type& impl,
+ Password_Callback callback, boost::system::error_code& ec)
{
- service_impl_.set_password_callback(impl, callback, error_handler);
+ return service_impl_.set_password_callback(impl, callback, ec);
}
private:
Index: stream.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/ssl/stream.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- stream.hpp 14 Jun 2006 22:26:31 -0000 1.1
+++ stream.hpp 8 Nov 2006 05:32:12 -0000 1.2
@@ -26,10 +26,10 @@
#include <boost/asio/detail/pop_options.hpp>
#include <boost/asio/error.hpp>
-#include <boost/asio/error_handler.hpp>
#include <boost/asio/ssl/basic_context.hpp>
#include <boost/asio/ssl/stream_base.hpp>
#include <boost/asio/ssl/stream_service.hpp>
+#include <boost/asio/detail/throw_error.hpp>
namespace boost {
namespace asio {
@@ -68,9 +68,6 @@
/// The type of the lowest layer.
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
- /// The type used for reporting errors.
- typedef typename next_layer_type::error_type error_type;
-
/// The type of the service that will be used to provide stream operations.
typedef Service service_type;
@@ -159,11 +156,13 @@
* @param type The type of handshaking to be performed, i.e. as a client or
as
* a server.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void handshake(handshake_type type)
{
- service_.handshake(impl_, next_layer_, type, throw_error());
+ boost::system::error_code ec;
+ service_.handshake(impl_, next_layer_, type, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Perform SSL handshaking.
@@ -174,17 +173,12 @@
* @param type The type of handshaking to be performed, i.e. as a client or
as
* a server.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void handshake(handshake_type type, Error_Handler error_handler)
+ boost::system::error_code handshake(handshake_type type,
+ boost::system::error_code& ec)
{
- service_.handshake(impl_, next_layer_, type, error_handler);
+ return service_.handshake(impl_, next_layer_, type, ec);
}
/// Start an asynchronous SSL handshake.
@@ -199,7 +193,7 @@
* completes. Copies will be made of the handler as required. The equivalent
* function signature of the handler must be:
* @code void handler(
- * const boost::asio::error& error, // Result of operation
+ * const boost::system::error_code& error // Result of operation.
* ); @endcode
*/
template <typename Handler>
@@ -213,11 +207,13 @@
* This function is used to shut down SSL on the stream. The function call
* will block until SSL has been shut down or an error occurs.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
void shutdown()
{
- service_.shutdown(impl_, next_layer_, throw_error());
+ boost::system::error_code ec;
+ service_.shutdown(impl_, next_layer_, ec);
+ boost::asio::detail::throw_error(ec);
}
/// Shut down SSL on the stream.
@@ -225,17 +221,11 @@
* This function is used to shut down SSL on the stream. The function call
* will block until SSL has been shut down or an error occurs.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*/
- template <typename Error_Handler>
- void shutdown(Error_Handler error_handler)
+ boost::system::error_code shutdown(boost::system::error_code& ec)
{
- service_.shutdown(impl_, next_layer_, error_handler);
+ return service_.shutdown(impl_, next_layer_, ec);
}
/// Asynchronously shut down SSL on the stream.
@@ -247,7 +237,7 @@
* completes. Copies will be made of the handler as required. The equivalent
* function signature of the handler must be:
* @code void handler(
- * const boost::asio::error& error, // Result of operation
+ * const boost::system::error_code& error // Result of operation.
* ); @endcode
*/
template <typename Handler>
@@ -266,7 +256,7 @@
*
* @returns The number of bytes written.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*
* @note The write_some operation may not transmit all of the data to the
* peer. Consider using the @ref write function if you need to ensure that
all
@@ -275,7 +265,10 @@
template <typename Const_Buffers>
std::size_t write_some(const Const_Buffers& buffers)
{
- return service_.write_some(impl_, next_layer_, buffers, throw_error());
+ boost::system::error_code ec;
+ std::size_t s = service_.write_some(impl_, next_layer_, buffers, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
}
/// Write some data to the stream.
@@ -286,25 +279,19 @@
*
* @param buffers The data to be written to the stream.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation.
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*
- * @returns The number of bytes written. Returns 0 if an error occurred and
- * the error handler did not throw an exception.
+ * @returns The number of bytes written. Returns 0 if an error occurred.
*
* @note The write_some operation may not transmit all of the data to the
* peer. Consider using the @ref write function if you need to ensure that
all
* data is written before the blocking operation completes.
*/
- template <typename Const_Buffers, typename Error_Handler>
+ template <typename Const_Buffers>
std::size_t write_some(const Const_Buffers& buffers,
- Error_Handler error_handler)
+ boost::system::error_code& ec)
{
- return service_.write_some(impl_, next_layer_, buffers, error_handler);
+ return service_.write_some(impl_, next_layer_, buffers, ec);
}
/// Start an asynchronous write.
@@ -321,8 +308,8 @@
* Copies will be made of the handler as required. The equivalent function
* signature of the handler must be:
* @code void handler(
- * const boost::asio::error& error, // Result of operation.
- * std::size_t bytes_transferred // Number of bytes written.
+ * const boost::system::error_code& error, // Result of operation.
+ * std::size_t bytes_transferred // Number of bytes written.
* ); @endcode
*
* @note The async_write_some operation may not transmit all of the data to
@@ -345,7 +332,7 @@
*
* @returns The number of bytes read.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read function if you need to ensure that
the
@@ -354,7 +341,10 @@
template <typename Mutable_Buffers>
std::size_t read_some(const Mutable_Buffers& buffers)
{
- return service_.read_some(impl_, next_layer_, buffers, throw_error());
+ boost::system::error_code ec;
+ std::size_t s = service_.read_some(impl_, next_layer_, buffers, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
}
/// Read some data from the stream.
@@ -365,25 +355,19 @@
*
* @param buffers The buffers into which the data will be read.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation.
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*
- * @returns The number of bytes read. Returns 0 if an error occurred and the
- * error handler did not throw an exception.
+ * @returns The number of bytes read. Returns 0 if an error occurred.
*
* @note The read_some operation may not read all of the requested number of
* bytes. Consider using the @ref read function if you need to ensure that
the
* requested amount of data is read before the blocking operation completes.
*/
- template <typename Mutable_Buffers, typename Error_Handler>
+ template <typename Mutable_Buffers>
std::size_t read_some(const Mutable_Buffers& buffers,
- Error_Handler error_handler)
+ boost::system::error_code& ec)
{
- return service_.read_some(impl_, next_layer_, buffers, error_handler);
+ return service_.read_some(impl_, next_layer_, buffers, ec);
}
/// Start an asynchronous read.
@@ -400,8 +384,8 @@
* Copies will be made of the handler as required. The equivalent function
* signature of the handler must be:
* @code void handler(
- * const boost::asio::error& error, // Result of operation.
- * std::size_t bytes_transferred // Number of bytes read.
+ * const boost::system::error_code& error, // Result of operation.
+ * std::size_t bytes_transferred // Number of bytes read.
* ); @endcode
*
* @note The async_read_some operation may not read all of the requested
@@ -425,12 +409,15 @@
*
* @returns The number of bytes read.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
template <typename Mutable_Buffers>
std::size_t peek(const Mutable_Buffers& buffers)
{
- return service_.peek(impl_, next_layer_, buffers, throw_error());
+ boost::system::error_code ec;
+ std::size_t s = service_.peek(impl_, next_layer_, buffers, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
}
/// Peek at the incoming data on the stream.
@@ -441,20 +428,15 @@
*
* @param buffers The buffers into which the data will be read.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation.
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*
- * @returns The number of bytes read. Returns 0 if an error occurred and the
- * error handler did not throw an exception.
+ * @returns The number of bytes read. Returns 0 if an error occurred.
*/
- template <typename Mutable_Buffers, typename Error_Handler>
- std::size_t peek(const Mutable_Buffers& buffers, Error_Handler error_handler)
+ template <typename Mutable_Buffers>
+ std::size_t peek(const Mutable_Buffers& buffers,
+ boost::system::error_code& ec)
{
- return service_.peek(impl_, next_layer_, buffers, error_handler);
+ return service_.peek(impl_, next_layer_, buffers, ec);
}
/// Determine the amount of data that may be read without blocking.
@@ -464,11 +446,14 @@
*
* @returns The number of bytes of data that can be read without blocking.
*
- * @throws boost::asio::error Thrown on failure.
+ * @throws boost::system::system_error Thrown on failure.
*/
std::size_t in_avail()
{
- return service_.in_avail(impl_, next_layer_, throw_error());
+ boost::system::error_code ec;
+ std::size_t s = service_.in_avail(impl_, next_layer_, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
}
/// Determine the amount of data that may be read without blocking.
@@ -476,19 +461,13 @@
* This function is used to determine the amount of data, in bytes, that may
* be read from the stream without blocking.
*
- * @param error_handler A handler to be called when the operation completes,
- * to indicate whether or not an error has occurred. Copies will be made of
- * the handler as required. The function signature of the handler must be:
- * @code void error_handler(
- * const boost::asio::error& error // Result of operation
- * ); @endcode
+ * @param ec Set to indicate what error occurred, if any.
*
* @returns The number of bytes of data that can be read without blocking.
*/
- template <typename Error_Handler>
- std::size_t in_avail(Error_Handler error_handler)
+ std::size_t in_avail(boost::system::error_code& ec)
{
- return service_.in_avail(impl_, next_layer_, error_handler);
+ return service_.in_avail(impl_, next_layer_, ec);
}
private:
Index: stream_service.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/asio/ssl/stream_service.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- stream_service.hpp 14 Jun 2006 22:26:31 -0000 1.1
+++ stream_service.hpp 8 Nov 2006 05:32:12 -0000 1.2
@@ -83,11 +83,11 @@
}
/// Perform SSL handshaking.
- template <typename Stream, typename Error_Handler>
- void handshake(impl_type& impl, Stream& next_layer,
- stream_base::handshake_type type, Error_Handler error_handler)
+ template <typename Stream>
+ boost::system::error_code handshake(impl_type& impl, Stream& next_layer,
+ stream_base::handshake_type type, boost::system::error_code& ec)
{
- service_impl_.handshake(impl, next_layer, type, error_handler);
+ return service_impl_.handshake(impl, next_layer, type, ec);
}
/// Start an asynchronous SSL handshake.
@@ -99,11 +99,11 @@
}
/// Shut down SSL on the stream.
- template <typename Stream, typename Error_Handler>
- void shutdown(impl_type& impl, Stream& next_layer,
- Error_Handler error_handler)
+ template <typename Stream>
+ boost::system::error_code shutdown(impl_type& impl, Stream& next_layer,
+ boost::system::error_code& ec)
{
- service_impl_.shutdown(impl, next_layer, error_handler);
+ return service_impl_.shutdown(impl, next_layer, ec);
}
/// Asynchronously shut down SSL on the stream.
@@ -114,11 +114,11 @@
}
/// Write some data to the stream.
- template <typename Stream, typename Const_Buffers, typename Error_Handler>
+ template <typename Stream, typename Const_Buffers>
std::size_t write_some(impl_type& impl, Stream& next_layer,
- const Const_Buffers& buffers, Error_Handler error_handler)
+ const Const_Buffers& buffers, boost::system::error_code& ec)
{
- return service_impl_.write_some(impl, next_layer, buffers, error_handler);
+ return service_impl_.write_some(impl, next_layer, buffers, ec);
}
/// Start an asynchronous write.
@@ -130,11 +130,11 @@
}
/// Read some data from the stream.
- template <typename Stream, typename Mutable_Buffers, typename Error_Handler>
+ template <typename Stream, typename Mutable_Buffers>
std::size_t read_some(impl_type& impl, Stream& next_layer,
- const Mutable_Buffers& buffers, Error_Handler error_handler)
+ const Mutable_Buffers& buffers, boost::system::error_code& ec)
{
- return service_impl_.read_some(impl, next_layer, buffers, error_handler);
+ return service_impl_.read_some(impl, next_layer, buffers, ec);
}
/// Start an asynchronous read.
@@ -146,19 +146,19 @@
}
/// Peek at the incoming data on the stream.
- template <typename Stream, typename Mutable_Buffers, typename Error_Handler>
+ template <typename Stream, typename Mutable_Buffers>
std::size_t peek(impl_type& impl, Stream& next_layer,
- const Mutable_Buffers& buffers, Error_Handler error_handler)
+ const Mutable_Buffers& buffers, boost::system::error_code& ec)
{
- return service_impl_.peek(impl, next_layer, buffers, error_handler);
+ return service_impl_.peek(impl, next_layer, buffers, ec);
}
/// Determine the amount of data that may be read without blocking.
- template <typename Stream, typename Error_Handler>
+ template <typename Stream>
std::size_t in_avail(impl_type& impl, Stream& next_layer,
- Error_Handler error_handler)
+ boost::system::error_code& ec)
{
- return service_impl_.in_avail(impl, next_layer, error_handler);
+ return service_impl_.in_avail(impl, next_layer, ec);
}
private:
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs