0

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?
4

1 回答 1

0
paquet = message.toUtf8() + '\n'; 
于 2013-11-06T15:38:38.630 回答