immediate notice if peer disappears
I'm using a lot of JXTA sockets, and after a long learning process it is now starting to work nicely. I have however noticed something intrigueing, and lack the in-depth knowledge to figure out what's happening here. I tried digging through the source code, but without any luck.
My question is: what might be the magic signal or event that seems to tell other peers - almost instantly - that a peer has gone off-line?
For detecting if a socket has dropped unexpectedly - e.g. somebody has pulled a network cable on the other side of the planet - the usual approach is to do a ping-like exchange, i.e. request some info and if it doesn't come within the time-out period you just assume that the line has dropped. This approach is typically invoked at the moment that you need the socket, i.e. too late. If my application would get some magic signal as soon as the line drops, a separate thread can then create a replacement socket to another peer, and this alternative line will then be available as soon as it is needed.
It really looks as if JXTA has a mysterious way of immediately notifying connected peers that a line has dropped. I saw this when I was monitoring a handfull of processes on a single computer, with JXTAsockets to each other. I killed one of the peers out of the blue, and all other windows almost immediately produced a JXTA warning message that the socket to peer so-and-so had closed. There was definitely no "clean" closeFromRemote() call, because my application doesn't have that kind of sophistication (yet). Perhaps some brave JXTA destructor manages to squeeze out a warning cry, just before dying?
I would very much like to learn how to detect this "connection gone" warning at application level. One bad way of doing it would be to scan these JXTA log messages internally in my application, filter for the one that says that the connection has dropped, and then throw an exception. This is a rather sloppy way of programming: if one day the magic JXTA log message is changed, my application won't work anymore.
Could it be that this only works on a local computer or local network, with multicast switched on? In that case it won't be possible in my application, unfortunately, because it's strictly unicast.
Thank you very much for any light on this matter....