summaryrefslogtreecommitdiff
path: root/louloulibs/network/tcp_client_socket_handler.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-03-14 21:45:23 +0100
committerlouiz’ <louiz@louiz.org>2017-03-14 21:45:23 +0100
commit0ab40dc1ab4e689921da54080b135e1d22b1c586 (patch)
tree238ac477aa6b29a8d1e187a8d97ecbcbbbc663ef /louloulibs/network/tcp_client_socket_handler.hpp
parent2d3806152e854ace7533fc3ad34d4ac1c44e9687 (diff)
downloadbiboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.gz
biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.bz2
biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.tar.xz
biboumi-0ab40dc1ab4e689921da54080b135e1d22b1c586.zip
Refactoring louloulibs and cmake
Use OBJECT libraries Remove the louloulibs directory Write FOUND variables in the cache
Diffstat (limited to 'louloulibs/network/tcp_client_socket_handler.hpp')
-rw-r--r--louloulibs/network/tcp_client_socket_handler.hpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/louloulibs/network/tcp_client_socket_handler.hpp b/louloulibs/network/tcp_client_socket_handler.hpp
deleted file mode 100644
index 74caca9..0000000
--- a/louloulibs/network/tcp_client_socket_handler.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma once
-
-#include <network/tcp_socket_handler.hpp>
-
-class TCPClientSocketHandler: public TCPSocketHandler
-{
- public:
- TCPClientSocketHandler(std::shared_ptr<Poller>& poller);
- ~TCPClientSocketHandler();
- /**
- * Connect to the remote server, and call on_connected() if this
- * succeeds. If tls is true, we set use_tls to true and will also call
- * start_tls() when the connection succeeds.
- */
- void connect(const std::string& address, const std::string& port, const bool tls);
- void connect() override final;
- /**
- * Called by a TimedEvent, when the connection did not succeed or fail
- * after a given time.
- */
- void on_connection_timeout();
- /**
- * Called when the connection is successful.
- */
- virtual void on_connected() = 0;
- bool is_connected() const override;
- bool is_connecting() const override;
-
- std::string get_port() const;
-
- void close() override final;
- std::chrono::system_clock::time_point connection_date;
-
- /**
- * Whether or not this connection is using the two given TCP ports.
- */
- bool match_port_pairt(const uint16_t local, const uint16_t remote) const;
-
- protected:
- bool hostname_resolution_failed;
- /**
- * Address to bind the socket to, before calling connect().
- * If empty, it’s equivalent to binding to INADDR_ANY.
- */
- std::string bind_addr;
- /**
- * Display the resolved IP, just for information purpose.
- */
- void display_resolved_ip(struct addrinfo* rp) const;
- private:
- /**
- * Initialize the socket with the parameters contained in the given
- * addrinfo structure.
- */
- void init_socket(const struct addrinfo* rp);
- /**
- * DNS resolver
- */
- Resolver resolver;
- /**
- * Keep the details of the addrinfo returned by the resolver that
- * triggered a EINPROGRESS error when connect()ing to it, to reuse it
- * directly when connect() is called again.
- */
- struct addrinfo addrinfo{};
- struct sockaddr_in6 ai_addr{};
- socklen_t ai_addrlen{};
-
- /**
- * Hostname we are connected/connecting to
- */
- std::string address;
- /**
- * Port we are connected/connecting to
- */
- std::string port;
-
- uint16_t local_port{};
-
- bool connected;
- bool connecting;
-};