Ejemplo n.º 1
0
void QSocketPrivate::setSocketDevice( QSocket *q, QSocketDevice *device )
{
    delete socket;
    delete rsn;
    delete wsn;

    if ( device ) {
	socket = device;
    } else {
	socket = new QSocketDevice( QSocketDevice::Stream,
				    ( addr.isIPv4Address() ?
				      QSocketDevice::IPv4 :
				      QSocketDevice::IPv6 ), 0 );
	socket->setBlocking( FALSE );
	socket->setAddressReusable( TRUE );
    }

    rsn = new QSocketNotifier( socket->socket(),
			       QSocketNotifier::Read, q, "read" );
    wsn = new QSocketNotifier( socket->socket(),
			       QSocketNotifier::Write, q, "write" );

    QObject::connect( rsn, SIGNAL(activated(int)), q, SLOT(sn_read()) );
    rsn->setEnabled( FALSE );
    QObject::connect( wsn, SIGNAL(activated(int)), q, SLOT(sn_write()) );
    wsn->setEnabled( FALSE );
}