in reply to Re^2: Non closing sockets - threads
in thread Non closing sockets - threads
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" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Non closing sockets - threads
by igor1212 (Novice) on Dec 16, 2008 at 08:48 UTC | |
by zentara (Cardinal) on Dec 16, 2008 at 14:13 UTC | |
by gone2015 (Deacon) on Dec 16, 2008 at 21:00 UTC | |
by BrowserUk (Patriarch) on Dec 16, 2008 at 22:29 UTC | |
by gone2015 (Deacon) on Dec 16, 2008 at 23:40 UTC |