Protocol specifications?

I'm currently learning Python and in this process, I'm re-writing mocstat (the Perl script that puts 'currently playing'-information on my desktop via Conky). I'm still getting information from MOC via `mocp --info`, which is either very cpu intensive or very inaccurate, depending on the delay. So I would like to ask the MOC server directly via the socket about playing information, just like the interface does.
Is there any information about the protocol anywhere? I couldn't find anything.
If the protocol isn't documented, could you provide some information about what to send and how to receive the answer, so I could get the same information from the socket as I get from `mocp --info`? I tried to read the sources, but my C skills are too weak, so any information would be appreciated.

Some progress

After hours of trial and error I somehow managed to catch events like EV_CTIME and EV_STATE. Even requesting and reading the current file and state works fine.
But the most important thing, the tags of the currently playing song, doesn't work at all.
When I send CMD_GET_TAGS to the server, I get EV_DATA (as expected) followed by data. I expect this data to be some kind of string, but it's always the same bunch of nonsense: 12 times 0x0, 8 times 0xff and 4 times 0x0 again.
Maybe I'm reading it wrong? But wouldn't it have to change anyhow when I'm playing different songs? How does this represent tag data?
Any help would be greatly appreciated.

According to protocol.c (line

According to protocol.c (line 275ff, packet_buf_add_tags) that exactly describes the situation for 'no tags available'. Three empty strings preceded by their length (4 times 0 as a 32bit integer 0x00000000 makes 12 bytes 0x0). String of length zero is just nothing. Then you get two times -1 (0xFFFFFFFF) (no track, no time) plus one time zero (not filled flag, 0x00000000).

Is this helpful to you ?

First: Thank you. I was

First: Thank you. I was really stuck there.

This is helpful indeed. Now I know what moc tells me. Looking at what `mocp --info` does (line 3594; interface.c) might indicate that I'm using the wrong command, as CMD_GET_TAGS is only used when the file type of the currently playing file equals to F_URL. Does that mean, CMD_GET_TAGS is only used for internet streams?

That would mean that I have to use CMD_GET_FILE_TAGS. I tried that before and the server dumped me for my request. I think it's because I'm doing something wrong when sending the file name. Is a char in C one byte long? And how long is it in Python? How do I do byte crafting in Python anyhow?
I think I have to read some more documentation.

As far as I understand it,

As far as I understand it, for files you have to use the CMD_GET_FILE_TAGS command. followed by the length of the string as a 32bit integer and then the character data (without terminating zero).
After that you need to specify the wanted tags (time and/or comment) (32bit).
If you sent the terminating zero (if there is such a thing in python, there is in C), the request would be illegal because this would result in a strange tags specification.
In C and Python, strings are composed of 8bit integers. Python also has unicode strings. They are formed by typing u'my string' (leading u).
If you don't use unicode strings you should be able to just write the string to the socket - maybe you need to check for that terminating zero...
I'm not sure how Python can do explicit type casting.

Good luck :-)

Thanks, again. Byte crafting

Thanks, again.

Byte crafting in Python is done via unpack() and pack(). Now the server never stops talking to me. (:

Next thing to do is putting everything in shape. I think, I'm putting this into a Python module. When it looks usable, I'm gonna post it here.