D 2.0 Sockets

Kai Ninomiya kainino1 at gmail.com
Mon May 3 00:27:22 PDT 2010


Hello all,

A friend and I recently attempted to write a simple bidirectional 
networking (eg. chat) application in D 2.0. We ran into some trouble, 
and as this was the first time we had dealt with sockets we struggled 
with it quite a bit. We then tried very similar code in Java (in case of 
an error in the D2 libraries, possibly), we didn't have much trouble at 
all getting it up and running.

The problems we encountered in D2, as best as I can remember them, were 
(a) enabling blocking on sockets did not seem to work, and (b) sending 
packets back from client to server caused the server to receive either 
nothing or an empty packet (I don't remember).

So here is my request: Could someone with some experience in sockets 
more-or-less-translate the following C code into a very simple D2 
example with similar functionality? (As I said, it might turn out to be 
a library problem, though I couldn't find any messages or bug reports 
about it.)

Thanks in advance.

http://www.linuxhowtos.org/data/6/server.c
http://www.linuxhowtos.org/data/6/client.c
(from http://www.linuxhowtos.org/C_C++/socket.htm)


More information about the Digitalmars-d-learn mailing list