www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - socket problems

I have to connect to a server that sends data in the format "ndnd....", 
where n is the length and d the data (or chunk).

The length of each chunk is calculated like this:
len = one_byte_from_stream();
if(len < 128)
{
    len++;
}
else
{
    len = (len & 0x1f) + 1;
    int ext = ((one_byte_from_stream() & 0x60) >> 5);
    int i;
    for(i = 0; i < ext; i++)
       len += one_byte_from_stream() << i * 8 + 5);
}

If the calculated length is available from socket, read the chunk here and 
calculate next length. On every chunk MultiDelegate!(int, char[]) onChunk 
should fire. I have tried different things, with sockets and queues, but 
nothing worked for me.

Anyone who can give me an advice for the socketpart?

Greets
# HTML 
Oct 04 2007