C++ Minecraft Packet
#6
(02-24-2012, 05:31 AM)Chlorek Wrote: And this is my problem, how to send this lenght along a string? I think (but I am not sure), I can not send short and string at same time.
I am going to do like this:
send(sock, (char*)HANDSHAKE, 2, 0); /*HANDSHAKE = 0x02*/
send(sock, (char*)sLenght, 2, 0); /*sLenght is a short with string lenght*/
send(sock, "Chlorek", 7, 0");

I see server after recv() changes packets to integer, and it dectects chlorek (first character of it) as packet 99. What am I doing wrong? I am begginer sockets, so I really thanx you for trying to help me.

I fixed it for you
Code:
char PacketID = HANDSHAKE;
send(sock, &PacketID , 1, 0); /*HANDSHAKE = 0x02*/
send(sock, (char*)&sLenght, 2, 0); /*sLenght is a short with string lenght*/
send(sock, "Chlorek", 7, 0");

Also, look here if you haven't already
http://mc.kev009.com/Protocol
Reply
Thanks given by:


Messages In This Thread
C++ Minecraft Packet - by Chlorek - 02-24-2012, 03:28 AM
RE: C++ Minecraft Packet - by FakeTruth - 02-24-2012, 03:44 AM
RE: C++ Minecraft Packet - by Chlorek - 02-24-2012, 04:01 AM
RE: C++ Minecraft Packet - by FakeTruth - 02-24-2012, 04:43 AM
RE: C++ Minecraft Packet - by Chlorek - 02-24-2012, 05:31 AM
RE: C++ Minecraft Packet - by FakeTruth - 02-24-2012, 06:05 AM
RE: C++ Minecraft Packet - by Chlorek - 02-24-2012, 06:13 AM
RE: C++ Minecraft Packet - by Chlorek - 02-25-2012, 02:50 AM



Users browsing this thread: 2 Guest(s)