Re: IP Routing QTcpSocket
Oh goody... another app with a network thread. And a broken one too since the received() slot runs in the main thread. Oh... a cross-thread direct signal-slot connection... That's certainly not the proper way to do it...
Re: IP Routing QTcpSocket
:)
thanks but sorry this answer s no closer to helpful
Re: IP Routing QTcpSocket
Quote:
Problem is that it works fine in localhost but I need to know the way (or at least be referred to correct reading) so that I can transmit data over the internet.
Nothing special is required. Just put the correct address on the attempt to connect.
Quote:
From my understanding (correct me if I am wrong):
this application sends data to correct receiver's IP. But only to router. router does not send to correct machine with port 1590 (for this example) so data floats around.
Your application creates a connection to a given IP address (or fails) and then sends data. Your application has nothing to do with, and need not worry about, how your operating system and any intervening system makes that connection or delivers that data (e.g it could use IPoAC and your app will not know or care) . In the case of TCP you don't even have to worry about data arriving out of order etc.
If you have external systems, e.g. firewalls, in the way then that is nothing to do with Qt or your application.
Wysota's comments come from frustration at the number of programmers that write simple Qt client server code with threads. Threads are almost certainly unnecessary and just add complexity and a range of other potential problems.
Re: IP Routing QTcpSocket
Quote:
Originally Posted by
naturalpsychic
:)
thanks but sorry this answer s no closer to helpful
Ok, let's try to be more helpful. Remove the thread and it's likely your problems will vanish. If they don't, then have a look at your firewall settings.
Re: IP Routing QTcpSocket
Thanks to both of you. it clears a lot. I have respect for great people out there.
Is this a good idea to use QThreadPool [and QRunnable] instead???
if not even that then whats the best (and professional) way to manage multiple connections (clients) at the same time?
Re: IP Routing QTcpSocket
Quote:
Originally Posted by
naturalpsychic
Is this a good idea to use QThreadPool [and QRunnable] instead???
if not even that then whats the best (and professional) way to manage multiple connections (clients) at the same time?
You can handle multiple connections in the same (main) thread. You don't need any extra threads.
Re: IP Routing QTcpSocket
Quote:
Originally Posted by
wysota
You can handle multiple connections in the same (main) thread. You don't need any extra threads.
But what if server has to perform big task (and different for each client)??? isn't that going to block main thread?
Re: IP Routing QTcpSocket
Then the server can perform the task and not networking operations in the external thread. There is no point in spawning threads if you don't know if you are going to need them at all.