Example #1
0
void Q3Socket::connectToHost( const QString &host, Q_UINT16 port )
{
#if defined(Q3SOCKET_DEBUG)
    qDebug( "Q3Socket (%s)::connectToHost: host %s, port %d",
	    name(), host.ascii(), port );
#endif
    setSocketIntern( -1 );
    d->state = HostLookup;
    d->host = host;
    d->port = port;
    d->dns4 = new Q3Dns( host, Q3Dns::A );
    d->dns6 = new Q3Dns( host, Q3Dns::Aaaa );

    // try if the address is already available (for faster connecting...)
    tryConnecting();
    if ( d->state == HostLookup ) {
	connect( d->dns4, SIGNAL(resultsReady()),
		 this, SLOT(tryConnecting()) );
	connect( d->dns6, SIGNAL(resultsReady()),
		 this, SLOT(tryConnecting()) );
    }
}
Example #2
0
drone::connectionstatus Drone::connect()
{
	if(_connected.load())
	{
		return drone::connectionstatus::ALREADY_CONNECTED;
	}

	drone::connectionstatus status = tryConnecting();
	if(status == drone::connectionstatus::CONNECTION_ESTABLISHED)
	{
		_connected.store(true);
		notifyConnectionEstablished();
		notifyStatusListeners(isArmed() ? drone::status::ARMED : drone::status::DISARMED);
	}
	else
	{
		_connected.store(false);
	}
	return status;
}