Important: Please read the Qt Code of Conduct -

[SOLVED][Socket] manage of two different socket

  • 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

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

  • How can do in Qt and Java

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

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

  • 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

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

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

  • 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:(.*)$");

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

Log in to reply