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. [SOLVED][Socket] manage of two different socket
Qt 6.11 is out! See what's new in the release blog

[SOLVED][Socket] manage of two different socket

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 2.3k 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.
  • B Offline
    B Offline
    bkerdev
    wrote on last edited by
    #1

    Hello
    I have a server program developed in Qt
    A computer can connect to the server with a Qt Application
    A mobile phone (android programmed in Java) that can also connect to the server Qt
    The management of data reception and transmission differs.
    I want to know how to recognize the socket of the computer and the phone.
    Thank you

    Boris Bker

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Hi.
      Well, you can add some "identifier" in your exchange protocol.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bkerdev
        wrote on last edited by
        #3

        How can do in Qt and Java

        Boris Bker

        1 Reply Last reply
        0
        • IamSumitI Offline
          IamSumitI Offline
          IamSumit
          wrote on last edited by
          #4

          -Each socket whether it is of mobile or Computer is same .
          -Each socket has an unique address / socket id through which you can communicate between any devices mobile to mobile ,mobile to computer.
          To manage/recognize 2 different sockets use socket id/descriptor to read or write the data from client to server or vice -versa.

          Be Cute

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bkerdev
            wrote on last edited by
            #5

            What type can be identifier?
            Can you give me an example of the structure of the protocol?

            Boris Bker

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kqt-mr-nv6
              wrote on last edited by
              #6

              you must have developed some protocol for the required
              data exchange
              just add new identifier to the request codes
              so that after connection establishment
              you can first synchronize the connection
              then do all your stuff

              1 Reply Last reply
              0
              • B Offline
                B Offline
                bkerdev
                wrote on last edited by
                #7

                I'll try.
                This is the structure of my package for now
                @quint16-QString@
                quint16 represent size of message
                QString represent message

                Boris Bker

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kqt-mr-nv6
                  wrote on last edited by
                  #8

                  you can exchange some standard strings in the first couple of packets
                  so that you can differentiate between the device nodes

                  1 Reply Last reply
                  0
                  • IamSumitI Offline
                    IamSumitI Offline
                    IamSumit
                    wrote on last edited by
                    #9

                    Hello ,
                    You can make identifier in the following ways :
                    1)Using QString
                    e.g; "</Anroid>"+Msg;
                    2)Using XML //Recommend
                    e.g; <CMD><Type>Anroid</Type></CMD>
                    3)Using QRegExp (Regular Expression)
                    // Any message that starts with "/Anroid:"
                    QRegExp usersRegex("^/Anroid:(.*)$");

                    Be Cute

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      bkerdev
                      wrote on last edited by
                      #10

                      Thank you to help me.
                      I'll try to do with XML Recommend

                      Boris Bker

                      1 Reply Last reply
                      0

                      • Login

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