in reply to unclear TCP client session block

I think you need to close the connection in the thread that's running 'in the background'. Otherwise, the telnet client will wait for that duplicated connection to be closed, before it quits itself.

When I modify your code as follows, it works for me, i.e. telnet quits right away, as you expected:

sub sleeping { close shift; ... } ... elsif ( /^sleep|^s\n?\r?$/i ) { threads->create( \&sleeping, $client )->detach(); } ...

Replies are listed 'Best First'.
Re^2: unclear TCP client session block
by Evgenij (Initiate) on Aug 24, 2011 at 08:34 UTC

    Thank you Eliya! It's working!

    But why the thread that's running 'in the background' must know about connection?

    It's better if sleeping function knows only how to sleep and listeningClient function knows how to work with client.

    May be it's a bag in perl thread implementation?