Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. The Network Chat example

The Network Chat example

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 403 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Merlino
    wrote on last edited by
    #1

    Hello,

    I am studying the example called "Network chat", which unfortunately is not accompanied by great explanations or even comments.

    It uses a UDP socket to send a broadcast and find peers on the network. It then creates a TCP client connection to each recognized peer and a server TCP connection to receive connections from the others.
    At least that's what I understand.

    Now I was trying to modify it to not accept more than one connection from each ip, but for some reason the client connections proliferate, just change the port and I don't understand why.

    Anyone who knows the example or sockets well, can you help me?

    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Im not sure what went wrong with the example, after you changed it
      but I just wanted to point to this
      https://wiki.qt.io/WIP-How_to_create_a_simple_chat_application

      Its overall a better example. and far more info.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Merlino
        wrote on last edited by
        #3

        This is not the same example, but it may help. Thank you!

        1 Reply Last reply
        0
        • M Merlino

          Hello,

          I am studying the example called "Network chat", which unfortunately is not accompanied by great explanations or even comments.

          It uses a UDP socket to send a broadcast and find peers on the network. It then creates a TCP client connection to each recognized peer and a server TCP connection to receive connections from the others.
          At least that's what I understand.

          Now I was trying to modify it to not accept more than one connection from each ip, but for some reason the client connections proliferate, just change the port and I don't understand why.

          Anyone who knows the example or sockets well, can you help me?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @Merlino said in The Network Chat example:

          Now I was trying to modify it to not accept more than one connection from each ip, but for some reason the client connections proliferate, just change the port and I don't understand why.

          I don't know the example/code. But TCP/IP allows e.g. multiple same IP connections if one side uses a different port number. Your server will need to keep a lookup of the IP clients connected (or get it from the established connections) and reject any from a duplicate client IP address.

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved