question on buffer passed in to recvFrom

Matthew Caron matt.caron at redlion.net
Fri Dec 7 14:31:00 PST 2012


Hey folks.

Given a configured socket, called server, and the following code:

     Address fromAddress;
     void[] buffer[2048];
     long bytes;

     bytes = server.receiveFrom(buffer, fromAddress);

All works grand.

However, if I try to do:

     Address fromAddress;
     void[] buffer;
     long bytes;

     bytes = server.receiveFrom(buffer, fromAddress);

bytes comes back as 0, presumably because the buffer is too small.

Might anyone be able to explain why the standard library can't 
automatically size the buffer for me, before calling the underlying C 
library code, then return to me the correct size buffer which is 
automatically garbage collected?

Thanks in advance.
-- 
Matthew Caron, Software Build Engineer
Sixnet, a Red Lion business | www.sixnet.com
+1 (518) 877-5173 x138 office


More information about the Digitalmars-d-learn mailing list