Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. struct __attribute__ ((packed)) CITE_MSG_T
  2. {
  3. uint8_t msg_id;
  4. uint64_t key;
  5. uint16_t index;
  6. uint16_t parts;
  7. CITE_PART_T text;
  8. };
  9.  
  10. struct __attribute__ ((packed)) CITE_PART_T
  11. {
  12. uint16_t data_length;
  13. char* data;
  14. };
  15.  
  16. size_t receivedBytes = socket.receive_from(mutableBuf, serverEndpoint);
  17. sb.commit(receivedBytes);
  18.  
  19.  
  20. if (msgType == 0)
  21. {
  22. uint8_t errno_;
  23. is.read((char*)errno_, sizeof(errno_));
  24. sb.consume(receivedBytes);
  25. errno = __builtin_bswap64(errno_); // it is just a class member
  26. throw QaSProtocolClientException("Server returned error");
  27. }
  28.  
  29. replyMsg.msg_id = msgType;
  30. is.read((char*)&replyMsg.key, sizeof(replyMsg.key));
  31. is.read((char*)&replyMsg.index, sizeof(replyMsg.index));
  32. is.read((char*)&replyMsg.parts, sizeof(replyMsg.parts));
  33. is.read((char*)&replyMsg.text.data_length, sizeof(replyMsg.text.data_length));
  34. if (replyMsg.text.data != NULL)
  35. {
  36. delete[] replyMsg.text.data;
  37. }
  38. replyMsg.text.data = new char[replyMsg.text.data_length];
  39. is.read(replyMsg.text.data, htons(replyMsg.text.data_length));
  40. sb.consume(receivedBytes);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement