|
@@ -146,6 +146,9 @@ vector<string> IoMan::tokenizeInput(string in) {
|
|
|
return args;
|
|
|
}
|
|
|
|
|
|
+// callback for async connect, used to get timeout
|
|
|
+void connect_async_handler(const boost::system::error_code &error) { gIOMAN->errcode = error; }
|
|
|
+
|
|
|
bool IoMan::connect() {
|
|
|
tcp::endpoint *ep = NULL;
|
|
|
address addr;
|
|
@@ -161,7 +164,14 @@ bool IoMan::connect() {
|
|
|
// establish connection
|
|
|
printMessage(string(__PRETTY_FUNCTION__) + string(" connecting to ") + ipstring, debug);
|
|
|
ep = new tcp::endpoint(addr, port);
|
|
|
- tcpsock->connect(*ep, errcode);
|
|
|
+ // connect never returns would_block, initialize errcode so we can determine whats up
|
|
|
+ errcode = boost::asio::error::would_block;
|
|
|
+
|
|
|
+ tcpsock->async_connect(*ep, &connect_async_handler);
|
|
|
+
|
|
|
+ ios.run_for(std::chrono::seconds(5));
|
|
|
+
|
|
|
+ //~ tcpsock->connect(*ep, errcode);
|
|
|
if (errcode) {
|
|
|
root["error"] = errcode.message();
|
|
|
connected = false;
|