[Interest] Pass socket descriptor to external library

Thiago Macieira thiago.macieira at intel.com
Tue Oct 20 23:04:48 CEST 2015


On Tuesday 20 October 2015 14:17:53 Bob Hood wrote:
> I have an external library that implements a proprietary protocol with
> clients connected via a TCP socket.  I'm using Qt as the front end to deal
> with discovery (via Avahi) and connections (via QTcpServer).  For each
> incoming connection, I need to pass the raw socket descriptor returned by
> QTcpSocket::socketDescriptor() to the library interface for its exclusive
> use.
> 
> Are there any conflicts in doing this?

Yes. QTcpSocket will continue to read from this socket. You cannot stop it.

> I don't see anything in the QTcpSocket interface to "take ownership" of the
> low-level socket, so will the QTcpSocket instance sit quietly while the
> library functions use the descriptor?

No.

> Can I safely connect the disconnected() signal to know when the library
> closes the socket?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list