summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-21 21:04:39 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-12-24 14:03:40 +0100
commit983477084cbb78b00da249a301480175324e93fc (patch)
tree292e998621df4b640e0454d95e6d1082d0910dd8
parent2ecb637f0c4a97643962d1703f208d1b1baf7e9b (diff)
downloadbiboumi-983477084cbb78b00da249a301480175324e93fc.tar.gz
biboumi-983477084cbb78b00da249a301480175324e93fc.tar.bz2
biboumi-983477084cbb78b00da249a301480175324e93fc.tar.xz
biboumi-983477084cbb78b00da249a301480175324e93fc.zip
connect() returns a boolean
-rw-r--r--src/network/socket_handler.cpp5
-rw-r--r--src/network/socket_handler.hpp2
-rw-r--r--src/xmpp/xmpp_component.cpp4
-rw-r--r--src/xmpp/xmpp_component.hpp5
4 files changed, 9 insertions, 7 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.
*/
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 7810499..433f87a 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -46,9 +46,9 @@ XmppComponent::~XmppComponent()
{
}
-void XmppComponent::start()
+bool XmppComponent::start()
{
- this->connect("127.0.0.1", "5347");
+ return this->connect("127.0.0.1", "5347");
}
void XmppComponent::send_stanza(const Stanza& stanza)
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 15f8f2f..1a7fc6b 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -25,9 +25,10 @@ public:
void parse_in_buffer() override final;
/**
- * Connect to the XMPP server
+ * Connect to the XMPP server.
+ * Returns false if we failed to connect
*/
- void start();
+ bool start();
/**
* Serialize the stanza and add it to the out_buf to be sent to the
* server.