Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int m_u32ReconnectCount; // >0 means reconnecting char buf[1024];
- memset(buf, 0, sizeof(buf)); char *ptr = &buf[0]; // First 10 Bytes are packet header
- *(unsigned int*)ptr = 6 + 42; // Size of Packet Excluding this field
- ptr += sizeof(unsigned int);
- *(unsigned char*)ptr = 1; // Number of Message in Packet
- ptr += sizeof(unsigned char) * 6;
- *(unsigned short*)ptr = 42; // Size of Message
- ptr += sizeof(unsigned short);
- *(unsigned short*)ptr = 50001; // Type of Message (Logon Message)
- ptr += sizeof(unsigned short);
- strcpy(*ptr, "TEST-USER01"); // USER ID with maximum 12 characters
- ptr += sizeof(char) * 12;
- ptr += sizeof(char) * 12;
- *(unsigned int*)ptr = 20003; // Version of this API spec
- ptr += sizeof(unsigned int);
- ptr += sizeof(char) * 8;
- if (m_u32ReconnectCount == 0) {
- *(unsigned short*)ptr = 0; // Bitmap for logon options
- }
- else {
- *(unsigned short*)ptr |= 0x8000; // Bitmap for logon options
- }
- ptr += sizeof(unsigned short);
- int result = send(sock, buf, sizeof(unsigned int) + 6 + 42, 0);
- if (result == SOCKET_ERROR) {
- printf("OCG Socket Send Errorn");
- }
- else {
- printf("OCG Socket Send Successn");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement