I have an existing server which behaviour is similar to a router
configuration. You can connect to it and as soon as you have a command promt
you can send a command to the server. It executes it and sends back the
result and a command promt. Then you can send the next command...
There is no problem with this part. My code is able to establish the
connection, send and recive data until my client gets EOF. It means the
server broke the connection. I would like my client to be able to
reestablish the connection and this part is not working. Very much would
appreciate your help.
*Here is my header:*
class Connection : public boost::enable_shared_from_this< Connection >
friend class Hive;
// Posts data to be sent to the connection.
void Send(std::string message);
// Posts a recv for the connection to process. If total_bytes is 0, then
// as many bytes as possible up to GetReceiveBufferSize() will be
// waited for. If Recv is not 0, then the connection will wait for
// total_bytes before invoking OnRecv.
void Recv( int32_t total_bytes = 0 );
// Posts an asynchronous disconnect event for the object to process.
class Hive : public boost::enable_shared_from_this< Hive >
boost::shared_ptr< boost::asio::io_service::work > m_work_ptr;
// Returns the io_service of this object.
boost::asio::io_service & GetService();
// Polls the networking subsystem once from the current thread and
// Runs the networking system on the current thread. This function
// until the networking system is stopped, so do not call on a single
// threaded application with no other means of being able to call Stop
// unless you code in such logic.
// Stops the networking system. All work is finished and no more
// networking interactions will be possible afterwards until Reset is
// Restarts the networking system after Stop as been called. A new work
// object is created ad the shutdown flag is cleared.
*and here is my cpp:*