Next steps in fine tuning code.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 12 May 2010 15:40:03 +0000 (17:40 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 12 May 2010 15:40:03 +0000 (17:40 +0200)
src/ip_service.h
src/net_helper.cpp
src/net_helper.h
src/tcp_service.cpp
src/tcp_service.h

index 5e91b52..6a27b91 100644 (file)
@@ -24,7 +24,7 @@ public:
 
     virtual ~IPService() {};
 
-    virtual int connect(const std::string& _hostname, const std::string& _port) = 0;
+    virtual void connect(const std::string& _hostname, const std::string& _port) = 0;
 
     virtual std::string read_from_socket() = 0;
 
index 3035660..3d6039d 100644 (file)
@@ -15,10 +15,19 @@ using namespace std;
 
 
 /**
+ * Default Constructor.
+ */
+NetHelper::NetHelper()
+    : Log(new Logger())
+{
+    IPService::Ptr _ip_service_ptr(new TCPService());
+    IPServicePtr.swap(_ip_service_ptr);
+}
+
+
+/**
  * Constructor.
  * @param _log Logger
- * @param _host Host
- * @param _port Port
  */
 NetHelper::NetHelper( const Logger::Ptr _log )
     : Log(_log)
index b22ae55..777b83a 100644 (file)
@@ -28,6 +28,8 @@ public:
 
     typedef boost::shared_ptr<NetHelper> Ptr;
 
+    NetHelper();
+
     NetHelper(const Logger::Ptr _log);
 
     ~NetHelper();
index c8d4d7f..995e452 100644 (file)
@@ -37,9 +37,9 @@ TCPService::~TCPService()
 /**
  * Initiate a new session with the peer.
  * @param endpoint_iterator The enpoint iterator.
- * @return 0 if all is fine, throws boost::syste::system_error if something went wrong.
+ * @return throws boost::syste::system_error if something went wrong.
  */
-int TCPService::connect(const std::string& _host, const std::string& _port) throw (boost::system::system_error)
+void TCPService::connect(const std::string& _host, const std::string& _port) throw (boost::system::system_error)
 {
     // Init boost::system::error_code
     boost::system::error_code error_code;
@@ -82,7 +82,7 @@ int TCPService::connect(const std::string& _host, const std::string& _port) thro
     if ( error_code )
         throw boost::system::system_error(error_code);
 
-    return 0;
+    return;
 }
 
 
index 74cdb3f..b6926f5 100644 (file)
@@ -31,13 +31,13 @@ private:
 
 public:
 
-    typedef boost::shared_ptr<TCPService> Ptr;
+    //typedef boost::shared_ptr<TCPService> Ptr;
 
     TCPService();
 
     ~TCPService();
 
-    virtual int connect(const std::string& _hostname, const std::string& _port) throw (boost::system::system_error);
+    virtual void connect(const std::string& _hostname, const std::string& _port) throw (boost::system::system_error);
 
     std::string read_from_socket() throw (boost::system::system_error);