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