Tango Server Example
JJDuck via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 19 09:47:33 PDT 2014
reference:
Tango Server:
http://www.dsource.org/projects/tango/wiki/SocketServerExample
Tango Client:
http://www.dsource.org/projects/tango/wiki/SocketHelloExample
I'm referring to these two examples.
In the server Example, I strip off the client part and it becomes
as follow.
void main()
{
const int port = 8080;
// thread body for socket-listener
void run()
{
auto server = new ServerSocket (new IPv4Address(port));
// wait for requests
auto request = server.accept;
// write a response
request.output.write ("server replies 'hello'");
}
Cout("server started");
while (true )
{
// start server in a separate thread, and wait for it to start
(new Thread (&run)).start;
tango.core.Thread.thread_sleep (0.250);
}
}
Situation:
I have my server running and I open a client in another cmd
console window and it replied alright. But if I try to connect it
again second time, it freezes.
Why is that? I thought the server is constantly receiving
messages and replying, why would it freeze up and stop
responding? what went wrong?
please advise.
Thanks
More information about the Digitalmars-d-learn
mailing list