Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. unsigned int m_u32ReconnectCount; // >0 means reconnecting char buf[1024];
  2. memset(buf, 0, sizeof(buf)); char *ptr = &buf[0]; // First 10 Bytes are packet header
  3. *(unsigned int*)ptr = 6 + 42; // Size of Packet Excluding this field
  4. ptr += sizeof(unsigned int);
  5. *(unsigned char*)ptr = 1; // Number of Message in Packet
  6. ptr += sizeof(unsigned char) * 6;
  7. *(unsigned short*)ptr = 42; // Size of Message
  8. ptr += sizeof(unsigned short);
  9. *(unsigned short*)ptr = 50001; // Type of Message (Logon Message)
  10. ptr += sizeof(unsigned short);
  11. strcpy(*ptr, "TEST-USER01"); // USER ID with maximum 12 characters
  12. ptr += sizeof(char) * 12;
  13. ptr += sizeof(char) * 12;
  14. *(unsigned int*)ptr = 20003; // Version of this API spec
  15. ptr += sizeof(unsigned int);
  16. ptr += sizeof(char) * 8;
  17. if (m_u32ReconnectCount == 0) {
  18. *(unsigned short*)ptr = 0; // Bitmap for logon options
  19. }
  20. else {
  21. *(unsigned short*)ptr |= 0x8000; // Bitmap for logon options
  22. }
  23. ptr += sizeof(unsigned short);
  24. int result = send(sock, buf, sizeof(unsigned int) + 6 + 42, 0);
  25. if (result == SOCKET_ERROR) {
  26. printf("OCG Socket Send Errorn");
  27. }
  28. else {
  29. printf("OCG Socket Send Successn");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement