Reading data from the network without knowing the size of the buffer that is coming

Roman Sztergbaum rmscastle at gmail.com
Thu Mar 21 19:19:15 UTC 2019


On Thursday, 21 March 2019 at 18:27:56 UTC, Andre Pany wrote:
> On Thursday, 21 March 2019 at 16:54:01 UTC, Roman Sztergbaum 
> wrote:
>> [...]
>
> I am also not a  expert in this area. If the message received 
> from the server exceeds 256 bytes, you have to call the receive 
> message several times until you know you received all bytes.
>
> If the data received is smaller than 256 bytes, the array will 
> contain NULL (character 0 value in the ascii table). This you 
> might could use as indicator you received all values.
>
> Is the server really without protocol? If the server code is 
> under your control, you could switch to http, which has a 
> message length attribute.
>
> Ps. In case there is a network error, your program will 
> terminate (out contract throws Error) without any chance to 
> avoid this. You should throw an Exception at the end of method 
> body instead for resource issues.
>
> Kind regards
> Andre
Hello,

I didn't precise it, but i use unix local socket communication, 
the layer is the KERNEL, and not TCP. I think i cannot use module 
http then.

But, i'm surprise that is not an other way that's is more simple, 
i will wait for some other answers i think.

Thank's for your help


More information about the Digitalmars-d-learn mailing list