Hello All,

I have got one problem which is resolved in http://www.qtcentre.org/threads/57634-SOLVED-Unable-to-read-data-by-QDataStream .
But i want to know that, is there any other fastest way to read all the data from socket in a structure.

My current structure is
Qt Code:
  1. typedef struct hShakeAckPkt
  2. {
  3. unsigned short Id; // 0XFEFE
  4. unsigned short BlockSize; // 45
  5. int Reserved1[2]; // fill with 0
  6. unsigned short FeedType; // fill with 0
  7. unsigned short Reserved2[3]; // fill with 0
  8. unsigned short Major; // 1
  9. unsigned short Minor; // 4
  10. unsigned char ProgramId[21]; // "CTCL" rest with '\0'
  11.  
  12. }hShakeAckPkt;
  13.  
  14. QDataStream & operator << (QDataStream &out, const hShakeAckPkt &hand_shake_pkt);
  15. QDataStream & operator >> (QDataStream &in, hShakeAckPkt &hand_shake_pkt);
To copy to clipboard, switch view to plain text mode 

And the code for reading the data from the socket is
Qt Code:
  1. QDataStream &operator <<(QDataStream &out, const hShakeAckPkt &hand_shake_pkt)
  2. {
  3. out << hand_shake_pkt.Id;
  4. out << hand_shake_pkt.BlockSize;
  5.  
  6. for(int i = 0; i < 2; ++i)
  7. out << hand_shake_pkt.Reserved1[i];
  8.  
  9. out << hand_shake_pkt.FeedType;
  10.  
  11. for(int i = 0; i < 3; ++i)
  12. out << hand_shake_pkt.Reserved2[i];
  13.  
  14. out << hand_shake_pkt.Major;
  15. out << hand_shake_pkt.Minor;
  16.  
  17. for(int i = 0; i < 21; ++i)
  18. out << hand_shake_pkt.ProgramId[i];
  19.  
  20. return out;
  21. }
  22.  
  23. QDataStream &operator >>(QDataStream &in, hShakeAckPkt &hand_shake_pkt)
  24. {
  25. in >> hand_shake_pkt.Id;
  26. in >> hand_shake_pkt.BlockSize;
  27.  
  28. for(int i = 0; i < 2; ++i)
  29. in >> hand_shake_pkt.Reserved1[i];
  30.  
  31. in >> hand_shake_pkt.FeedType;
  32.  
  33. for(int i = 0; i < 3; ++i)
  34. in >> hand_shake_pkt.Reserved2[i];
  35.  
  36. in >> hand_shake_pkt.Major;
  37. in >> hand_shake_pkt.Minor;
  38.  
  39. for(int i = 0; i < 21; ++i)
  40. in >> hand_shake_pkt.ProgramId[i];
  41.  
  42. return in;
  43. }
To copy to clipboard, switch view to plain text mode 

Now i want to know that, is there any other fastest way to read all the data in structure memory. (With or without QDataStream)

?????