How to know when to close a socket?
I have a c++ application "A" that run a Java application "B".
My problem is how B could know if A is shut down/terminated?
B is open a new Socket -
ServerSocket m_serverSocket = new ServerSocket(m_portNumber);
Socket m_clientSocket = m_serverSocket.accept();
How can I know in the Java side if the c++ application is down and I need also to shut down the Java application?
Using "SetKeepAlive" will help me?
Re: How to know when to close a socket?
Keep Alive won't really help you, unless you don't mind it realizing that the application has been terminated an hour earlier (dependent on your OS actually...)
The fastest way to find out if the connection is still open is to try writing to the socket. It will throw an exception if the connection is closed.