I am trying to develop a client-server application. The server is Qt and Java client (android) I can receive data from the client. But when I send data to the client, receive it but not in the right format.
Code C++
QByteArray paquet;
QDataStream out(&paquet, QIODevice::WriteOnly);
out << message; // On ajoute le message
out << "\n";
// Envoi du paquet préparé à tous les clients connectés au serveur
for (int i = 0; i < clients.size(); i++)
{
clients[i]->write(paquet);
}
Code Java
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while(mRun) {
Log.e(TAG, "En attente de message");
mServerMessage = in.readLine();
if(mServerMessage != null && mMessageListener != null){
Log.e("REPONSE FROM SERVER", "S: Received Message: " + mServerMessage);
mMessageListener.messageReceived(mServerMessage);
}
}
out
?N?E?W?C?L?I?E?N?T?