A little of coordination for Rosettacode

Adam D. Ruppe destructionator at gmail.com
Sun Jun 16 15:30:31 PDT 2013


I made a network server/client that needs no library except 
Phobos. Came in a little under 500 lines but is quite generic:

http://arsdnet.net/dcode/server.d

The top of the file shows the usage program, then comes the code 
that could go in a library.

Basically you define an interface with a bunch of functions. The 
server writes a class that implements that interface and then 
mixes in the helper code that does the network talking. The 
network protocol is very basic, it just serializes the arguments 
and return values with function and sequence numbers to know what 
to call. The serializer only handles basic types, arrays, and 
some structs, it isn't much code.

On the client side, that class is automatically generated. It 
doesn't completely implement the interface though, because the 
functions are all async callbacks instead of return values.

Run it without arguments to be the server. Any arguments will 
cause it to be a client and connect to local host to run the 
example.


More information about the Digitalmars-d-learn mailing list