Hi, I'm using GServer and in "serve" method I read a string from a TCP socket:
line = io.gets("\n")
but it can occur that the TCP connection is closed so "gets" return NIL.
In this case I just one to terminate this thread, no more.
The only way I get it working is doing:
line = io.gets("\n")
Thread.current.terminate if !line # terminate = kill = exit
Is it the appropiate way? I read the method doc but don't understand
what exactly it does:
thr.terminate
Terminates thr and schedules another thread to be run,
returning the terminated Thread. If
this is the main thread, or the last thread, exits the process.
I think you can just return from the method and be happy. You can
also raise an exception which will be caught and logged as an error if
you set the debug attribute to a true value.
Marcelo
···
On Thu, Mar 27, 2008 at 11:31 AM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
The only way I get it working is doing:
line = io.gets("\n")
Thread.current.terminate if !line # terminate = kill = exit
On Thu, Mar 27, 2008 at 11:31 AM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
> The only way I get it working is doing:
>
> line = io.gets("\n")
> Thread.current.terminate if !line # terminate = kill = exit