Results 1 to 9 of 9

Thread: IP Routing QTcpSocket

  1. #1
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default IP Routing QTcpSocket

    I have very very simple network application based on QTcpSocket and QTcpServer. Client/Server in the same applicatino

    Click here to browse


    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.

    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.


    could I please get a better understading or could I please get help with how to implement it in a correct way in order to send it over WAN
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: IP Routing QTcpSocket



    thanks but sorry this answer s no closer to helpful
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: IP Routing QTcpSocket

    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.
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: IP Routing QTcpSocket

    Quote Originally Posted by naturalpsychic View Post


    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default 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?
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: IP Routing QTcpSocket

    Quote Originally Posted by naturalpsychic View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    44
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: IP Routing QTcpSocket

    Quote Originally Posted by wysota View Post
    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?
    Life is like a dream, sometimes it is good and somtimes it is bad, but in the end it is over

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to change mouse event routing?
    By kathy in forum Qwt
    Replies: 0
    Last Post: 7th June 2011, 16:06
  2. how to change mouse message routing?
    By kathy in forum Qt Quick
    Replies: 0
    Last Post: 24th May 2011, 21:59
  3. Routing stdout to Plain Text Edit
    By Barry79 in forum Qt Programming
    Replies: 7
    Last Post: 2nd April 2009, 13:06
  4. Somewhat OT, line routing for diagramming tool
    By pherthyl in forum Qt Programming
    Replies: 7
    Last Post: 20th October 2008, 19:23
  5. QT4.2.2 and QTcpSocket
    By Nyphel in forum Qt Programming
    Replies: 13
    Last Post: 11th March 2007, 11:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.