D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] OT: Java sockets

 

Does anyone know how to find out if a socket has been uncleanly 
disconnected in java? I've got a simple client/server connection which 
at the moment just joins stdin and stdout on each side, but when I 
ctrl-c the client the server part stays in the read/write loop so never 
accepts new connections.

I've set sotimeout (but I think that's only on accept() anyway), and 
getkeepalive() returns false, but isconnected() still returns true even 
if the client was killed.

So far all I've got off the net is that it should throw an exception if 
I read from or write to it, but reading from it will either block (which 
I don't want) or throw a sockettimeoutexception (if the client is 
waiting for data to stdin), which is exactly the same exception I get if 
the client was killed.

Any ideas?
Thanks
Simon

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html