Hello.

I have a question about the portability sending data between Windows and Linux or VxWorks.

I have this qt code to send data from a Windows machine.

Qt Code:
  1. QByteArray block;
  2. QDataStream out(&block, QIODevice::WriteOnly);
  3.  
  4. QString string = QString(QLatin1String(this->mensajeEnviar.mensaje)) ;
  5. out.setVersion(QDataStream::Qt_4_0);
  6. out << (quint16)0;
  7. out <<string;
  8. out.device()->seek(0);
  9. out << (quint16)(block.size() - sizeof(quint16));
  10.  
  11. if(tcpSocket->isWritable()){
  12.  
  13. tcpSocket->write(block);
  14.  
  15.  
  16. }
To copy to clipboard, switch view to plain text mode 

And the datas are arriving well when I use a qt program as receiver, but when i use the following c++ code to read in another machine the datas are not the expected.


Qt Code:
  1. // This is a wxworks command and in datagrama_rx char* type receives the sending datas.
  2.  
  3. if (recvfrom(descriptor, datagrama_rx, SIZE_DATAGRAMA, 0, (sockaddr *)&direccion_origen, &addr_len) !=ERROR)
  4.  
  5. mensajeRecibido.mensaje=datagrama_rx;
To copy to clipboard, switch view to plain text mode 

The problem is that datagrama_rx receives what I was written in block, i think the block.data() but when i do the assignation in mensajeRecibido.mensaje which is a char* too it is not well than and with qt code in windows it was working well.

I dont know if i am forgetting something important. Could somone help me?

Thank you in advance.