Update of /cvsroot/boost/boost/libs/asio/example/serialization
In directory 
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17073/libs/asio/example/serialization

Modified Files:
        Jamfile client.cpp connection.hpp server.cpp 
Log Message:
Change error handling to match TR2 proposal.


Index: Jamfile
===================================================================
RCS file: /cvsroot/boost/boost/libs/asio/example/serialization/Jamfile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Jamfile     25 Jul 2006 11:04:02 -0000      1.2
+++ Jamfile     8 Nov 2006 05:32:13 -0000       1.3
@@ -22,6 +22,7 @@
 
 exe client
   : <lib>@boost/libs/serialization/build/boost_serialization
+    <lib>@boost/libs/system/build/boost_system
     client.cpp
   : <include>$(BOOST_ROOT)
     <include>../../../..
@@ -34,6 +35,7 @@
 
 exe server
   : <lib>@boost/libs/serialization/build/boost_serialization
+    <lib>@boost/libs/system/build/boost_system
     server.cpp
   : <include>$(BOOST_ROOT)
     <include>../../../..

Index: client.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/asio/example/serialization/client.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- client.cpp  25 Jul 2006 11:04:02 -0000      1.2
+++ client.cpp  8 Nov 2006 05:32:13 -0000       1.3
@@ -41,7 +41,7 @@
   }
 
   /// Handle completion of a connect operation.
-  void handle_connect(const boost::asio::error& e,
+  void handle_connect(const boost::system::error_code& e,
       boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
   {
     if (!e)
@@ -72,7 +72,7 @@
   }
 
   /// Handle completion of a read operation.
-  void handle_read(const boost::asio::error& e)
+  void handle_read(const boost::system::error_code& e)
   {
     if (!e)
     {

Index: connection.hpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/asio/example/serialization/connection.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- connection.hpp      25 Jul 2006 11:04:02 -0000      1.2
+++ connection.hpp      8 Nov 2006 05:32:13 -0000       1.3
@@ -64,7 +64,7 @@
     if (!header_stream || header_stream.str().size() != header_length)
     {
       // Something went wrong, inform the caller.
-      boost::asio::error error(boost::asio::error::invalid_argument);
+      boost::system::error_code error(boost::asio::error::invalid_argument);
       socket_.io_service().post(boost::bind(handler, error));
       return;
     }
@@ -83,7 +83,9 @@
   void async_read(T& t, Handler handler)
   {
     // Issue a read operation to read exactly the number of bytes in a header.
-    void (connection::*f)(const boost::asio::error&, T&, boost::tuple<Handler>)
+    void (connection::*f)(
+        const boost::system::error_code&,
+        T&, boost::tuple<Handler>)
       = &connection::handle_read_header<T, Handler>;
     boost::asio::async_read(socket_, boost::asio::buffer(inbound_header_),
         boost::bind(f,
@@ -95,8 +97,8 @@
   /// a tuple since boost::bind seems to have trouble binding a function object
   /// created using boost::bind as a parameter.
   template <typename T, typename Handler>
-  void handle_read_header(const boost::asio::error& e, T& t,
-      boost::tuple<Handler> handler)
+  void handle_read_header(const boost::system::error_code& e,
+      T& t, boost::tuple<Handler> handler)
   {
     if (e)
     {
@@ -110,14 +112,16 @@
       if (!(is >> std::hex >> inbound_data_size))
       {
         // Header doesn't seem to be valid. Inform the caller.
-        boost::asio::error error(boost::asio::error::invalid_argument);
+        boost::system::error_code error(boost::asio::error::invalid_argument);
         boost::get<0>(handler)(error);
         return;
       }
 
       // Start an asynchronous call to receive the data.
       inbound_data_.resize(inbound_data_size);
-      void (connection::*f)(const boost::asio::error&, T&, 
boost::tuple<Handler>)
+      void (connection::*f)(
+          const boost::system::error_code&,
+          T&, boost::tuple<Handler>)
         = &connection::handle_read_data<T, Handler>;
       boost::asio::async_read(socket_, boost::asio::buffer(inbound_data_),
         boost::bind(f, this,
@@ -127,8 +131,8 @@
 
   /// Handle a completed read of message data.
   template <typename T, typename Handler>
-  void handle_read_data(const boost::asio::error& e, T& t,
-      boost::tuple<Handler> handler)
+  void handle_read_data(const boost::system::error_code& e,
+      T& t, boost::tuple<Handler> handler)
   {
     if (e)
     {
@@ -147,7 +151,7 @@
       catch (std::exception& e)
       {
         // Unable to decode data.
-        boost::asio::error error(boost::asio::error::invalid_argument);
+        boost::system::error_code error(boost::asio::error::invalid_argument);
         boost::get<0>(handler)(error);
         return;
       }

Index: server.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/asio/example/serialization/server.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- server.cpp  25 Jul 2006 11:04:02 -0000      1.2
+++ server.cpp  8 Nov 2006 05:32:13 -0000       1.3
@@ -62,7 +62,7 @@
   }
 
   /// Handle completion of a accept operation.
-  void handle_accept(const boost::asio::error& e, connection_ptr conn)
+  void handle_accept(const boost::system::error_code& e, connection_ptr conn)
   {
     if (!e)
     {
@@ -89,7 +89,7 @@
   }
 
   /// Handle completion of a write operation.
-  void handle_write(const boost::asio::error& e, connection_ptr conn)
+  void handle_write(const boost::system::error_code& e, connection_ptr conn)
   {
     // Nothing to do. The socket will be closed automatically when the last
     // reference to the connection object goes away.


-------------------------------------------------------------------------
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

Reply via email to