Unix sockets between C and Python Unix sockets between C and Python unix unix

Unix sockets between C and Python


This actually has nothing to do with Python and nothing to do with sockets, but you're right, it does have to do with endianness.

Test you're implicit assumption: is 84 really represented as 0x00 0x00 0x 00 0x54 on your computer that is running the C client program? Try writing to a file instead of a socket, and binary edit the result. I bet you'll see that your native architecture is little-endian, and that the data that was written was 0x54 0x00 0x00 0x00.

What you're seeing on the socket is simply what you're sending.


This is exactly endianness. The bits of a single byte are always in the same order, but the byte orders within a word might differ. And first you send a word consisting of 4 bytes, and they are received in opposite (i.e., big endian) order, but then in the second example you are sending your message byte-by-byte.