28 #include <config-network.h>
30 #include <QSocketNotifier>
39 using namespace KNetwork;
41 class KNetwork::KStreamSocketPrivate
44 KResolverResults::ConstIterator local, peer;
50 inline KStreamSocketPrivate()
66 QObject::connect(&d->timer, SIGNAL(
timeout()),
this, SLOT(timeoutSlot()));
87 return timeout() - d->startTime.elapsed();
95 d->timer.start(msecs);
105 if (!service.isNull())
127 if (!service.isNull())
142 QObject::connect(
this, SIGNAL(
hostFound()), SLOT(hostFoundSlot()));
157 if (!
blocking() && !d->timer.isActive())
159 d->timer.setSingleShot(
true);
209 void KStreamSocket::hostFoundSlot()
211 QObject::disconnect(
this, SLOT(hostFoundSlot()));
214 d->timer.setSingleShot(
true);
217 QTimer::singleShot(0,
this, SLOT(connectionEvent()));
220 void KStreamSocket::connectionEvent()
228 d->startTime.start();
232 d->peer = peer.begin();
236 while (d->peer != peer.end())
247 connectionSucceeded(r);
262 if (!bindLocallyFor(r))
285 QObject::connect(n, SIGNAL(activated(
int)),
286 this, SLOT(connectionEvent()));
290 QObject::connect(n, SIGNAL(activated(
int)),
291 this, SLOT(connectionEvent()));
298 connectionSucceeded(r);
317 void KStreamSocket::timeoutSlot()
329 QPointer<KStreamSocket> that =
this;
344 bool foundone =
false;
346 for (d->local = local.begin(); d->local != local.end(); ++d->local)
347 if ((*d->local).family() == peer.
family())
367 void KStreamSocket::connectionSucceeded(
const KResolverEntry& peer)
369 QObject::disconnect(
socketDevice()->readNotifier(), 0,
this, SLOT(connectionEvent()));
370 QObject::disconnect(
socketDevice()->writeNotifier(), 0,
this, SLOT(connectionEvent()));
380 emit
bound(*d->local);
384 #include "k3streamsocket.moc"