virtual std::string read_from_socket() = 0;
- virtual int write_to_socket(const std::string& data) = 0;
+ virtual void write_to_socket(const std::string& data) = 0;
virtual int close() = 0;
};
* Open the connection to the peer.
* @return 0 if all is fine, -1 on error.
*/
-int NetHelper::open_connection(const string& hostname, const string& port)
+int NetHelper::open_connection(const string& hostname, const string& port) const
{
try
{
~NetHelper();
- int open_connection(const std::string& _host, const std::string& _port);
+ int open_connection(const std::string& _host, const std::string& _port) const;
int send_data(const std::string& data);
/**
* Writes out given data to the socket.
* @param data The data which will be written to the socket.
- * @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::write_to_socket(const string& data) throw (boost::system::system_error)
+void TCPService::write_to_socket(const string& data) throw (boost::system::system_error)
{
// Get the data size which will be written
unsigned int data_size = data.size();
else if ( bytes_wrote != data_size )
throw boost::system::system_error(boost::system::error_code(ENOBUFS,boost::system::system_category),"Could not write all data to the socket.");
- return 0;
+ return;
}
std::string read_from_socket() throw (boost::system::system_error);
- int write_to_socket(const std::string& data) throw (boost::system::system_error);
+ void write_to_socket(const std::string& data) throw (boost::system::system_error);
int close() throw (boost::system::system_error);
};