|
@@ -146,6 +146,9 @@ vector<string> IoMan::tokenizeInput(string in) {
|
|
return args;
|
|
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() {
|
|
bool IoMan::connect() {
|
|
tcp::endpoint *ep = NULL;
|
|
tcp::endpoint *ep = NULL;
|
|
address addr;
|
|
address addr;
|
|
@@ -161,7 +164,14 @@ bool IoMan::connect() {
|
|
// establish connection
|
|
// establish connection
|
|
printMessage(string(__PRETTY_FUNCTION__) + string(" connecting to ") + ipstring, debug);
|
|
printMessage(string(__PRETTY_FUNCTION__) + string(" connecting to ") + ipstring, debug);
|
|
ep = new tcp::endpoint(addr, port);
|
|
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) {
|
|
if (errcode) {
|
|
root["error"] = errcode.message();
|
|
root["error"] = errcode.message();
|
|
connected = false;
|
|
connected = false;
|