in reply to Socket unpack

Read the spec. Google. Wikipedia. Not sure what you're expecting from us since you gave no info.

You need to know things such as field size, byte order and whether it's signed or not. (e.g. 32-bit unsigned integer, big-endian). Then you can use unpack to convert the data into Perl values. (unpack 'N' for the example type).

Replies are listed 'Best First'.
Re^2: Socket unpack
by Anonymous Monk on Feb 16, 2010 at 08:04 UTC

    Thats my problem. The spec. is unknown for me and there`s no guide on it.

    I am trying to automate something that is not documented.

    Is it possible to find out the field size/byte order ...etc ?

      Yes and no. How can you tell what the following means?

      00 00 00 40 00 10 43 55 00 00 00 01 00 00 00 00

      Judging by the placement of the NULs, what are probably big-endian 4-byte numbers stand out.

      00 00 00 40 00 10 43 55 00 00 00 01 00 00 00 05 ----------- ----------- -----------

      If it was stored in little-endian byte order, it would look like

      40 00 00 00 55 43 10 00 01 00 00 00 05 00 00 00 ----------- ----------- -----------

      00 00 00 40 is likely a 32-bit field with value 64. Do you have an idea of what data you are getting? Are you expecting 64 for anything or 64 of something? If you change the input, do you see a corresponding change there?

      But maybe 00 00 00 40 is two 16-bit fields. Or two bytes and one 16-bit, or ...

      Do you see any repeating patterns? You could be looking at a list of records. For example,

      06 00 00 00 00 00 00 00 3C 00 00 00 7A 2D 01 01 ........<...z-.. EC 4E 14 DE FF FF FF FF FF FF FF FF 7A 2D 01 01 .N..........z-.. ED 4E 14 DE FF FF FF FF FF FF FF FF 39 5A 01 27 .N..........9Z.' E8 62 F4 EA FF FF FF FF FF FF FF FF 39 5A 01 27 .b..........9Z.' E7 62 F4 EA FF FF FF FF FF FF FF FF 39 5A 01 27 .b..........9Z.' 76 5D AE E5 FF FF FF FF FF FF FF FF 39 5A 01 27 v]..........9Z.' ...

      appears to contains 16 byte records (starting after 12 bytes). There are 60 such records, so the preceding 3C 00 00 00 must be the number of records that follow.

      You could study the sender's source code, disassembling a binary if necessary. If you have access to another receiver, you could also study it.

      If you need to send something back, you'll need to study an existing client, or at least the communication between an exiting client and server.

      Nothing simple ahead.

        That`s way beyond my experience and skills.

        Is there some kind of a book or guide that explains it all.

        Do you suggest any reading

      I am trying to automate something that is not documented

      Are you sure? Perl is probably the most highly documented language around. So, I'd suggest reading perlipc for starters. Then post some code that you've tried.

        It's the communication protocol that's not documented.