The protocol is inferred by reading the source code of egd version 0.9. It is a simple binary protocol which contains 4 commands. When the client connects to EGD via unix sockets or TCP sockets, the client will initiate the communication by sending the request. The format of the request is dependent upon the nature of request; the first byte of the request will be the command code (0x01 to 0x04) that will tell the service the nature of the request.
Get Entropy Level
Client sends 1-byte value of 0x00
EGD replies with a 4-byte value indicating the current size of the entropy pool in big-endian order which will indicate the number of the random data that can be read without blocking.
Read Entropy (Non-Blocking Mode)
Client sends 1-byte value of 0x01 and 1-byte value indicating the number of bytes to request from the service. Up to 255 bytes of random data can be requested.
EGD replies (without delay) with a 1-byte value indicating the number of random data that will be returned after reading this first byte.
Read Entropy (Blocking Mode)
Client sends 1-byte value of 0x02 and 1-byte value indicating the number of bytes to request from the service. Up to 255 bytes of random data can be requested.
EGD replies (possibly with delay) with the requested random data. Note that there is no 1-byte value to indicate the number of returned random data as opposed to the non-blocking read request.
Client sends 1-byte value of 0x03, 2-bytes value reflecting the number of entropy bits that is being given in this request, 1-byte value reflecting the number of bytes of random data (for the entropy bits) and followed by the string of random data. So the length of request is 4+N bytes where N is the value of the 4th byte of request.
EGD does not reply to this request.
Client sends 1-byte value of 0x04.
EGD replies with a 1-byte value reflecting the length of pid string that will follow after this byte. Note that the pid string is not null-terminated.
That's all for this EGD client protocol. More in-depth knowledge of the workings of the EGD can be found in egd.pl. If you have some experience with Perl, the code is actually quite self-documenting. :-P