summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket_handler.cpp5
-rw-r--r--src/network/socket_handler.hpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/network/socket_handler.cpp b/src/network/socket_handler.cpp
index e3973f1..c1ad8ae 100644
--- a/src/network/socket_handler.cpp
+++ b/src/network/socket_handler.cpp
@@ -20,7 +20,7 @@ SocketHandler::SocketHandler():
throw std::runtime_error("Could not create socket");
}
-void SocketHandler::connect(const std::string& address, const std::string& port)
+bool SocketHandler::connect(const std::string& address, const std::string& port)
{
log_info("Trying to connect to " << address << ":" << port);
struct addrinfo hints;
@@ -47,13 +47,14 @@ void SocketHandler::connect(const std::string& address, const std::string& port)
{
log_info("Connection success.");
this->on_connected();
- return ;
+ return true;
}
log_info("Connection failed:");
perror("connect");
}
log_error("All connection attempts failed.");
this->close();
+ return false;
}
void SocketHandler::set_poller(Poller* poller)
diff --git a/src/network/socket_handler.hpp b/src/network/socket_handler.hpp
index 6678722..675d247 100644
--- a/src/network/socket_handler.hpp
+++ b/src/network/socket_handler.hpp
@@ -21,7 +21,7 @@ public:
/**
* Connect to the remote server, and call on_connected() if this succeeds
*/
- void connect(const std::string& address, const std::string& port);
+ bool connect(const std::string& address, const std::string& port);
/**
* Set the pointer to the given Poller, to communicate with it.
*/