Okay - problem has been solved, and I also have a slight confession.
I actually edited down my program a bit more than I should have when I posted it, and it didn't reflect it's true functionality. When a new socket was opened, I was immediately reading data with a sysread. (the first block of data after an open socket is supposed to contain the filename for the server to write the following data to, so I always assumed the client would be a 'good' client and have that data read to be read on open!) The code was hanging on that particular sysread. Sometimes the client requests an open socket and does not send any data. Why the code would just hang on sysread baffles me, but that is exactly what it was doing. I did have the code to process successfully read data, zero data, and undefined return from sysread, but in this one special cases it would never break out of the sysread function. Why is that?
My pared down code - and yours, too - gave me the idea to just accept the socket request and put it on the select queue to wait for data to be read. Problem solved. I now wait for data before reading it, and it now handles good and bad clients.
Many thanks for the help, monks. I hope this in turn can help other who experience the same situation. Don't assume clients will behave!
p.s. I would be interested if anyone has insight why sysread hangs in this sort of scenario...thx!
In reply to Re^2: socket select hangs after client restarts
by planetjeff
in thread socket select hangs after client restarts
by planetjeff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |