Results 1 to 3 of 3

Thread: Using multiple applications on same port? (UDP) [Solved]

  1. #1
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Using multiple applications on same port? (UDP) [Solved]

    Hi all,

    Currently, I am building a set of 4 programs that have to communicate with each other using the TCP sockets. Since I don't have experience with network programming, I took the chat example (link) and pretty much build my applications on top of this.

    Somehow one of the programs can only aquire data from one of the other programs, instead of all 3 other programs. To see what went wrong, I tested the example mentioned above.

    When this example gets opened 4 times on the same machine, not all clients get connected to each other. When a message is sent in one client, it is not received in all other clients. (You can test this yourself to see what I mean).

    This makes some sense because since the application uses UDP, and the used port is hardcoded, this means that all instances of the application use the same port (using shareAddress). When I change the port number that one of the programs uses, this program does not receive any data at all.

    So my question is: Can you give me directions to a way to make all 4 programs communicate with each other using the TCP sockets?

    If you need to see some code, please tell me which part and I will post it for you.

    Thanks in advance!
    Last edited by DrDonut; 3rd June 2010 at 15:39.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Using multiple applications on same port? (UDP)

    Some tips:
    1. Learn how peer to peer works
    2. Learn about broadcasting messages
    3. The most easy and ready made solution, connect 4 clients to a single server, let your server handle all the messages.

    For solution 3, example:
    Client 1 wants to send something to client 3, but they are not connected to each other. No problem, send a message to the server and tell the server to send it to client 3. etc. Just like a chat application would work. Every client is a client, not a server.

    If you want every client to be a server too, see peer to peer. There's a bittorrent example in the Qt docs too.

  3. The following user says thank you to tbscope for this useful post:

    DrDonut (3rd June 2010)

  4. #3
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using multiple applications on same port? (UDP)

    Thanks, I think the central server idea is the best one, I will look into that.

    DrDonut

Similar Threads

  1. Applications don't start
    By gls in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 22nd September 2007, 07:36
  2. Distributing multiple Qt applications?
    By gfunk in forum Qt Programming
    Replies: 5
    Last Post: 23rd August 2007, 18:41
  3. what's the matter with my qt applications?
    By xylosper in forum Qt Programming
    Replies: 4
    Last Post: 12th June 2007, 18:25
  4. Deploying QT applications
    By SteM in forum Installation and Deployment
    Replies: 3
    Last Post: 6th June 2007, 11:08
  5. Replies: 0
    Last Post: 21st December 2006, 12:48

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.