Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, May 2007
QSslSocket::socketDescriptor()


Message 1 in thread

QSslSocket::socketDescriptor() appears to always return -1 instead of
returning the descriptor of the underlying socket being used to transfer the
encrypted data stream.  It would be nice if this could be fixed.

-- 
 [ signature omitted ] 

Message 2 in thread

Mark Sawle wrote:
> QSslSocket::socketDescriptor() appears to always return -1 instead of
> returning the descriptor of the underlying socket being used to transfer
> the
> encrypted data stream.  It would be nice if this could be fixed.

Are you calling socketDescriptor() before or after your connection has been
established?

-- 
 [ signature omitted ] 

Message 3 in thread

Andreas Aardal Hanssen <ahanssen@xxxxxxxxxxxxx> wrote:

> Mark Sawle wrote:
> > QSslSocket::socketDescriptor() appears to always return -1 instead of
> > returning the descriptor of the underlying socket being used to transfer
> > the encrypted data stream.  It would be nice if this could be fixed.
> 
> Are you calling socketDescriptor() before or after your connection has
> been established?

After.

-- 
 [ signature omitted ] 

Message 4 in thread

Mark Sawle <mark@xxxxxxxxxxxxxx> wrote:

> QSslSocket::socketDescriptor() appears to always return -1 instead of
> returning the descriptor of the underlying socket being used to transfer the
> encrypted data stream.  It would be nice if this could be fixed.

QSslSocket::peerAddress() also suffers from a similar problem and returns a
null QHostAddress instead of the correct address.  I'm willing to bet that
localAddress(), localPort() and peerPort() will be affected too.

-- 
 [ signature omitted ] 

Message 5 in thread

Mark Sawle wrote:
> Mark Sawle <mark@xxxxxxxxxxxxxx> wrote:
>> QSslSocket::socketDescriptor() appears to always return -1 instead of
>> returning the descriptor of the underlying socket being used to transfer
>> the
>> encrypted data stream.  It would be nice if this could be fixed.
> QSslSocket::peerAddress() also suffers from a similar problem and returns
> a
> null QHostAddress instead of the correct address.  I'm willing to bet that
> localAddress(), localPort() and peerPort() will be affected too.

Those were fixed very recentely; all the properties you are trying to access
should be updated when the connection has been established, but not before.

As for socketDescriptor(), that's a bug, and here's a fix:

--- 4.3/src/network/qabstractsocket.cpp  2007/04/13 15:56:03.000000000
+++ 4.3/src/network/qabstractsocket.cpp  2007/05/09 08:39:51.000000000
@@ -972,6 +972,7 @@
         peerPort = socketEngine->peerPort();
         localAddress = socketEngine->localAddress();
         peerAddress = socketEngine->peerAddress();
+        cachedSocketDescriptor = socketEngine->socketDescriptor();
     }

     state = QAbstractSocket::ConnectedState;

--- 4.3/src/network/qsslsocket.cpp  2007/05/08 15:18:33.000000000
+++ 4.3/src/network/qsslsocket.cpp  2007/05/08 16:04:09.000000000
@@ -1576,6 +1576,8 @@
     q->setPeerPort(plainSocket->peerPort());
     q->setPeerAddress(plainSocket->peerAddress());
     q->setPeerName(plainSocket->peerName());
+    cachedSocketDescriptor = plainSocket->socketDescriptor();
+
 #ifdef QSSLSOCKET_DEBUG
     qDebug() << "QSslSocket::_q_connectedSlot()";
     qDebug() << "\tstate =" << q->state();


-- 
 [ signature omitted ] 

Message 6 in thread

Andreas Aardal Hanssen <ahanssen@xxxxxxxxxxxxx> wrote:

> Mark Sawle wrote:
> > QSslSocket::peerAddress() also suffers from a similar problem and
> > returns a null QHostAddress instead of the correct address.  I'm willing
> > to bet that localAddress(), localPort() and peerPort() will be affected
> > too.
> 
> Those were fixed very recentely; all the properties you are trying to
> access should be updated when the connection has been established, but not
> before.

So I see, but the properties aren't set as the result of calling
QSslSocket::setSocketDescriptor() which is why I wasn't seeing them.

> As for socketDescriptor(), that's a bug, and here's a fix:

Thanks very much for that; works perfectly.

-- 
 [ signature omitted ] 

Message 7 in thread

Mark Sawle wrote:
>> Those were fixed very recentely; all the properties you are trying to
>> access should be updated when the connection has been established, but
>> not before.
> So I see, but the properties aren't set as the result of calling
> QSslSocket::setSocketDescriptor() which is why I wasn't seeing them.

I think you'll see from more recent snapshots that those props are set
correctly. :-)

-- 
 [ signature omitted ] 

Message 8 in thread

Andreas Aardal Hanssen <ahanssen@xxxxxxxxxxxxx> wrote:

> Mark Sawle wrote:
> > > Those were fixed very recentely; all the properties you are trying to
> > > access should be updated when the connection has been established, but
> > > not before.
> > So I see, but the properties aren't set as the result of calling
> > QSslSocket::setSocketDescriptor() which is why I wasn't seeing them.
> 
> I think you'll see from more recent snapshots that those props are set
> correctly. :-)

Ah, so they are.  Thanks! :)

-- 
 [ signature omitted ]