PDA

View Full Version : QSocket: connecting but not connected



olberg
5th May 2006, 14:08
I am trying to write a simple program using a QSocket to send messages to a server listening on port 50002. I can get the QSocket to go to state "Connecting", but not connected. The server also registers the incoming connection, but no messages are passed to the server.

Does the client program at present does not use slots, does it have to. In the current version I simply loop with 1 second sleeps and wait for the state to change to "Connected". Alas, this never happens :confused:

My program looks very much like the client from the QSocket documentation, but no slots. The server is even identical (except for port number).

Do I _have_ to implement a slot for the "connected" signal for this to work?

regards,
Michael

jacek
5th May 2006, 14:17
Does the client program at present does not use slots, does it have to. In the current version I simply loop with 1 second sleeps and wait for the state to change to "Connected".
Unfortunately, in Qt3 you must use signals & slots mechanism for QSocket. This means also that you can't wait in a loop for it to connect.

wysota
5th May 2006, 22:18
You could use QSocketNotifier here (I think -- I never used it myself).

olberg
8th May 2006, 10:26
Thanks, my little program works now, using slots. I have been using QSocketNotifier before and I am convinced that would work, too. I wanted something quick and dirty here, that's why I hadn't used slots right away in this example.