Ok, i've looked in a lot of places, and on google, and it seems that google is perforated with "packet sniffer" and that not what I want, in other words I cant find what I wanted.

I'm working on upgrading my server to the latest version of the client (public server api) and the packet protocol has changed... im not good with packets yet, so i would like help on how to set this up. the login packet is set up like this:

Packet id - 1 byte

version - int - 4 bytes

username - string - UTF-8 encoded string. First two bytes is a short describing the number of bytes in the string.

password - string - UTF-8 encoded string. First two bytes is a short describing the number of bytes in the string.


in the old version it was easy, because each packet was a set length, so i could read it easily.... with this new setup i cant figure out how to make it receive the packet, split it into its respective parts... easily

I made a little mod that will get me the username and "password" but it is buggy and doesnt get me the version... any help would be appreciated, a link to a simple introduction to receiving packets like this wouldn't be bad either.

Thanks

Recommended Answers

All 2 Replies

One way to handle this is to read all the received data in to a byte array.
Then parse the byte array to exctract what you need.

Another is to parse the stream as you read it byte by byte (or block by block).
However, this can lead to the read blocking if the packet is incomplete.

The byte array idea is the one i originally went with, and i must have screwed it up somewhere, because it would occasionally throw an error, ill give it another shot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.