Android Socket event when other side closes?
<p>I'm writing software for an Android device that's used as a remote control for an industrial process run by a program on a PC.     The PC is always listening and the Android device opens the connection to the PC using the Android Socket class.   After that happens it can send commands or request data.  (so I guess you could think of the Android as the client and the PC as the server).    </p>

<p>Either side can close the connection.  On the PC there's a WinSock event handler which gets called when the Android closes the connection, but I don't know how to do the same thing on the Android side.   I didn't see anything in the Android Socket documentation (<a href="http://developer.android.com/reference/java/net/Socket.html" rel="nofollow">http://developer.android.com/reference/java/net/Socket.html</a>) about events or callbacks.    How can my code be notified when the PC has asynchronously closed the connection so I can notify the user, close my end of the connection, or take other action in response?</p>

<p>Thanks in advance.</p>
