Exchange of data through socket connection.

Adam D. Ruppe destructionator at gmail.com
Sun Dec 27 17:57:23 UTC 2020


On Sunday, 27 December 2020 at 17:49:10 UTC, BPS wrote:
> 	void[] buff;
> 	incommingConn.receive(buff);

this has no actual space to receive anything

> 	void[] buff = ['a', 's', 'd', 'f'];
> 	sock.send(buff);
> 	sock.receive(buff);

and the return value needs to be checked to tell you how much 
actually got received.


The Phobos socket api is a very thin wrapper over the C function 
and work basically the same way: you must pre-allocate buffers 
and check return values.

I wrote about it at length in my blog last year:

http://dpldocs.info/this-week-in-d/Blog.Posted_2019_11_11.html

so I'll just point you there instead of repeating much more, 
there's full examples on the link with comments describing the 
details of what is going on.

You probably want the "Communication by stream" part of the table 
of contents and can jump there, but the whole page might be 
helpful.


More information about the Digitalmars-d-learn mailing list