socket problems

HowToMeetLadies xcc666 at gmail.com
Thu Oct 4 11:16:02 PDT 2007


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 



More information about the Digitalmars-d-learn mailing list