No thanks....sounds like work. :-)
You seem to be isolating the problem, what you need to do now is simplify your example for testing/debugging. Always try to start with the simplest setup, get it working, then add complexity. In your case, just try testing 2 GPS devices, and simplify your thread code (or even remove it and just go with IO::Select), until you see disconnects. Try removing all those If statements, and just have super simple code, like:
Then start building from there. You should be able to turn off your device, and see what happens. Play with simple code until it's working under your control.if($lclient->connected){ print "1\n"; } else{ print "not connected\n" }
I have a feeling that your GPS devices may not be acting like a regular computer would, and you may need to put some IO::Select code into your thread code, so you can use it's can_read, can_write, and has_exception methods to detect problems in the GPS device. You can setup IO::Select to run on just the single client in each thread, like this untested pseudocode:
my $sel = new IO::Select(); $sel->add($lclient); if($lclient->connected){ print "connected\n"; print "can read\n" if ($sel->can_read); print "can write\n" if ($sel->can_write); print "has exception\n" if ($sel->has_exception); } else{ print "not connected\n" }
In reply to Re^3: Non closing sockets - threads
by zentara
in thread Non closing sockets - threads
by igor1212
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |