Oh I forgot to mention that when it's not a timeout, when it's a proper disconnect, everything works fine and gets EOF and exits properly, the thread dies properly, etc.
Basically it's just
while(1)
{
while (my $connection = $main->accept) {
threads->create(\&initplayer,$connection);
}
then
sub initplayer {
my $hand = shift;
$hand->blocking(0);
print "INITPLAYER CALLED!\n";
threads->detach;
doplayer($hand,$hand,$hand);
remove_player($hand);
print "THREAD DESTROYED!\n";
$hand->close();
}
and doplayer contains the code I posted before. I added a print line inside the while loop and it continues to print after the timeout, so it's not a blocking issue.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.