Changeset 14577 for trunk/FACT++


Ignore:
Timestamp:
11/07/12 12:03:03 (12 years ago)
Author:
tbretz
Message:
Improved StartConnect to get rid of a misleading error at startup of most programs.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Connection.cc

    r14179 r14577  
    399399    }
    400400
    401     tcp::resolver resolver(get_io_service());
     401    const bool valid = !fAddress.empty() || !fPort.empty();
    402402
    403403    boost::system::error_code ec;
    404404
    405     tcp::resolver::query query(fAddress, fPort);
    406     tcp::resolver::iterator iterator = resolver.resolve(query, ec);
    407 
    408405    ostringstream msg;
    409     if (!fAddress.empty() || !fPort.empty() || ec)
     406    if (!valid)
     407        msg << "No target address... connection attempt postponed.";
     408    else
     409    {
     410        tcp::resolver resolver(get_io_service());
     411
     412        tcp::resolver::query query(fAddress, fPort);
     413        tcp::resolver::iterator iterator = resolver.resolve(query, ec);
     414
    410415        msg << "Trying to connect to " << URL() << "...";
    411416
    412     if (ec)
    413         msg << " " << ec.message() << " (" << ec << ")";
     417        // Start connection attempts (will also reset deadline counter)
     418        if (!ec)
     419            AsyncConnect(iterator);
     420        else
     421            msg << " " << ec.message() << " (" << ec << ")";
     422    }
    414423
    415424    // Only output message if it has changed
     
    423432    }
    424433
    425     if (ec)
     434    if (!valid || ec)
    426435        AsyncWait(fConnectionTimer, 250, &Connection::HandleConnectionTimer);
    427     else
    428         // Start connection attempts (will also reset deadline counter)
    429         AsyncConnect(iterator);
    430436}
    431437
Note: See TracChangeset for help on using the changeset viewer.