summaryrefslogtreecommitdiff
path: root/src/network/socket_handler.hpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-27 01:01:44 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-27 01:01:44 +0200
commit5507adbe9473f4b41e52d16498f14850773e5e45 (patch)
tree34f2960edf6b73828537460cc50e6cdb9252a5e3 /src/network/socket_handler.hpp
parent6b0ffb5fc2eca537e2cfaf24acb8a4d2ca9b99f1 (diff)
downloadbiboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.gz
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.bz2
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.tar.xz
biboumi-5507adbe9473f4b41e52d16498f14850773e5e45.zip
SocketHandlers own the poller and add themself into it only when the socket is created
We want to call socket() with the parameters provided by getaddrinfo, so we can’t addd the fd into the poller immediately. We need to wait the connection attempt, and then the SocketHandler can call add_socket_handler itself, if the connection succeeds, or is in progress.
Diffstat (limited to 'src/network/socket_handler.hpp')
-rw-r--r--src/network/socket_handler.hpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/network/socket_handler.hpp b/src/network/socket_handler.hpp
index f554350..1e31dcd 100644
--- a/src/network/socket_handler.hpp
+++ b/src/network/socket_handler.hpp
@@ -6,6 +6,7 @@
#include <netdb.h>
#include <utility>
+#include <memory>
#include <string>
#include <list>
@@ -22,7 +23,7 @@ class Poller;
class SocketHandler
{
public:
- explicit SocketHandler();
+ explicit SocketHandler(std::shared_ptr<Poller> poller);
virtual ~SocketHandler() {}
/**
* (re-)Initialize the socket
@@ -34,10 +35,6 @@ public:
void connect(const std::string& address, const std::string& port);
void connect();
/**
- * Set the pointer to the given Poller, to communicate with it.
- */
- void set_poller(Poller* poller);
- /**
* Reads data in our in_buf and the call parse_in_buf, for the implementor
* to handle the data received so far.
*/
@@ -119,7 +116,7 @@ protected:
* And a raw pointer because we are not owning it, it is owning us
* (actually it is sharing our ownership with a Bridge).
*/
- Poller* poller;
+ std::shared_ptr<Poller> poller;
/**
* Hostname we are connected/connecting to
*/