#close filehandle before detached thread dies out print "closing lclient $lclient\n"; close( $lclient); #remove multi-echo-clients from echo list @clients = grep {$_ !~ $lfileno} @clients; print "exiting thread .....clients = @clients\n";
The clients are always connected to the server, except when is some network outage or other gprs disconnections. Then, clients reconnects to the server And there is my problem: Old threads remains connected to the server and I need to get rid of them!
An interesting problem, but it seems that the disconnect should be detected. I wish I had a test setup with many GPS devices to test with.
The first thing that comes to mind, is to keep a hash of connected GPS devices, tracking their id and fileno's, and check for duplicate connections in your server->accept. Another thing is maybe try a different test in your thread for being connected. The connected method returns the address if connected, so maybe you can track addresses, and be sure there are no duplicate addresses?
Maybe try a shorter timeout value? A timeout of 500 is a long time, and may be allowing your device to reconnect before the thread detects the old connection is gone?
In reply to Re: Non closing sockets - threads
by zentara
in thread Non closing sockets - threads
by igor1212
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |