Tango Server Example
JJDuck via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 19 12:03:58 PDT 2014
I solved it.
void main()
{
const int port = 8080;
auto server = new ServerSocket (new IPv4Address(port));
Cout("server started").flush;
while (true )
{
// wait for requests
auto request = server.accept;
// write a response
//
// start server in a separate thread, and wait for it to start
(new Thread (
{
// do lots of things here or add some functions for processing
request.output.write ("server replies 'hello'");
request.close;
})).start;
}
}
More information about the Digitalmars-d-learn
mailing list