Running Qt Example client/server not working
-
@marlenet15
Ok so in linux it find right ip I guess. ( im on win)
yes local host is that 127.x.x.x ip.
And i use it for server IP. + the listed port.Are u running both samples on same machine?
It works here both for win 7 and win 10.
-
@mrjj I am doing exactly as you are telling me but nothing. Also, I am using Threaded Fortune Server. Are you using that as well?
So in my Threaded Fortune Server I have :
IP: 192.168.1.209
port: 45127In my fortune client I have:
Server name: localhost
port: 45127 -
@marlenet15
nope, im using the "simple" ones.local host should work if both server and client is run on same machine.
I will check tomorrow when i have a linux to see.
-
@marlenet15
That's really, really strange. Could you run the client code through the debugger? What would be the TCP error the client gets?
(I don't have Qt 4 to test, sorry).Kind regards.
-
@kshegunov Ok So I used the regular Fortune Server and it works. So I am wondering why with the Threaded Fortune Server it does not work. The thing is I need to use threaded server.
-
@marlenet15 said:
So I am wondering why with the Threaded Fortune Server it does not work. The thing is I need to use threaded server.
Well, perhaps the example is broken; it has happened. But in any case the threaded fortune server is not really a good example of a threaded TCP server, not for real work anyway.
Kind regards.
-
@kshegunov Do you know of any good examples? Thank you.
-
@marlenet15
Honestly, no. But I was about to write something as an example for a library of mine, so I'll post when I have it.
Meanwhile, you should look up how to use the asynchronous TCP socket API in Qt and make your code work in single thread. Look here for example. When that's done it takes very little modification to make it work in multiple threads.Kind regards.
-
@kshegunov Thank you so much!
-
@marlenet15
Hi,
Here you can find a threaded TCP server example. You can ignore the module specific classesQDaemonApplication
(think of it asQCoreApplication
) andQDaemonLog
you can substitute withQDebug
.Enjoy!
Kind regards.