[Qt-interest] Alternative for bind() in TCP sockets
Arnold Krille
arnold at arnoldarts.de
Wed Jan 19 09:02:33 CET 2011
On Wednesday 19 January 2011 05:03:15 Anisha Kaul wrote:
> Greetings to all,
>
> Yes of course this question must have been asked a thousand times before
> and I did search Google before posting here but couldn't get a
> satisfactory answer.
>
> bind() is not available for the TCP sockets in QT, so would someone be
> kind enough to suggest the alternative/workaround for that?
You are searching the wrong class. Tcp has connections, so normally you create
a server (lets call it QTcpServer) and make it listen() on a certain port.
Then when a client (using QTcpSocket) establishes a connection to that port,
it emits a signal like newConnection() upon which your program fetches all
pending connections from that server with nextPendingConnection() and gets
back pointers to QTcpSocket which are already open with the connection to the
client. [*]
Its only the connectionless udp where multiple connections can be handled by
the same socket. Mainly because there are no connections, only incoming
datagrams...
Have fun,
Arnold
[*] Similarities to existing classes and functions are purely coincidental.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110119/630e007e/attachment.bin
More information about the Qt-interest-old
mailing list