Exploring the Network Protocol

Discussion in 'Development General' started by wandering scripter, Sep 15, 2014.

  1. wandering scripter

    wandering scripter New Member

    Joined:
    Apr 24, 2010
    Messages:
    12
    Likes Received:
    0
    Long time no see guys, got a few questions going forward as I have a project I'd like to start on, but I'm not going to talk about that so much until I actually find out if I can do it or not, so here's my questions.

    1. is https://github.com/po-devs/pokemon-online/wiki/Network-Protocol current?
    2. (Assuming 1 is accurate):
    • 4 bytes for the packet length l. First byte is l/256*256*256, last byte is l modulo 256
    4 bytes, so is this an integer, which I modify the first and last bytes for first? If not, what is the proper way to read the packet length?

    Thanks!
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    All you need to do, is read the first 4 bytes, then unpack it as a long integer in whatever language you use.

    I use Python and how it's done there is
    Code (PYTHON):
    1.  
    2. length = socket.recv(4) #first four bytes
    3. length = struct.unpack("!I", length)[0] #gets the long integer, I = fmt character for long integer
    4. data = socket.recv(length) # gets the rest of the data
    5.  
    And sending you just need to pack it up in the same way