D Lang Socket Programming Example

Savsak savsaktheteam at gmail.com
Fri Sep 6 13:47:53 PDT 2013


Hi Friends,

Socket programming with the D programming language is the most 
simple way how to do it

For example, the sample with Tango, but not by phobos

How do I do this with a simple, but phobos


import tango.io.Stdout;

import tango.net.Socket;
import tango.net.ServerSocket;
import tango.net.SocketConduit;

int main() {
     Socket server = new Socket(AddressFamily.UNIX,
                                SocketType.STREAM,
                                ProtocolType.IP);

     while(true) {
         Socket client = server.accept();

         char[1024] buffer;
         client.receive(buffer);

         Stdout.format("The client said'{}'.", buffer);

         client.shutdown(SocketShutdown.BOTH);
         client.detach();
     }
     return 0;
}


More information about the Digitalmars-d mailing list