IRC / std.sockets question
Adam D. Ruppe
destructionator at gmail.com
Mon Jan 13 19:53:17 PST 2014
On Tuesday, 14 January 2014 at 03:42:29 UTC, APott wrote:
> byte[] buffer;
> client.receive(buffer);
These lines are wrong: receive needs a pre-allocated buffer with
a certain size and it tries to fill it. Also generally ubyte is
better for this than byte.
ubyte[1024] buffer;
auto got= client.receive(buffer);
if(got < 0) throw new Exception("error");
if(got == 0) writeln("end of file)
else auto receivedInfo = buffer[0 .. got]; /* use received info */
More information about the Digitalmars-d
mailing list