• Welcome to Valhalla Legends Archive.
 

[C -> S] 0x51

Started by Trunning, May 07, 2010, 10:24 PM

Previous topic - Next topic
|

Hdx

You forgot to call recv()
You created the buffer, but you never filled it with anything.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

#106
Oh that was stupid, and you will never guess what happened. I was failing to send packet 0x3E correctly, so I checked my packet log, seen there was an extra 4 bytes there, and fixed it by myself, so it appears I've learned something.

How can I get the IP Address from the IP DWORD? It says on the page to use ntohs() for the port, but doesn't say about the IP Address.

rabbit

Each byte is a block, in "standard" order.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Trunning

Oh and real quick, is it giving me the IP and Port of the Realm Server I'm suppose to connect to or no?

rabbit

Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Trunning

Can I get an example on how to convert the DWORD IP to an actual IP Address?

307491135 is the DWORD

3f f1 53 12 are the 4 bytes

63.241.83.18 is the actual IP

lord2800

Quote from: Trunning on May 11, 2010, 01:12 PM
Can I get an example on how to convert the DWORD IP to an actual IP Address?

307491135 is the DWORD

3f f1 53 12 are the 4 bytes

63.241.83.18 is the actual IP

Each byte is one octet of the IP address. sprintf("%d.%d.%d.%d", byte[0] byte[1], byte[2], byte[3]); would do the trick.

Trunning

There's 4 DWORDS before the IP DWORD, so 17 through 20 should work, but [17] always prints out -15.

printf("\n%d.%d.%d.%d\n", buffer[17], buffer[18], buffer[19], buffer[20]);

Hdx

-15 = F1
Figure it out from there! (Hint: What does F1 =?)

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

241? What was the -15 to F1 conversion, I thought the 15 was decimal, but that's what 241 is.

Hdx

-15 as a byte in binary is 11110001
241 as a byte in binary is 11110001
It's just a problem with signed vs unsigned.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

Ok then, how do I convert the decimal version to an actual IP in C++?

Hdx

(unsigned byte)buffer[17]; should work.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

It creates a hole lot of errors trying to type cast to "unsigned byte", any idea why?

l)ragon

CString str_ip = inet_ntoa(addr);
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

|