Socket closed after a time with no activity
843790Apr 25 2007 — edited May 2 2007Hello everyone:
First of all I want to apologize because of my English.
I'm developing a chat application with a C++ server and a Java client. My problem is that when the client stays a while without receiving any data from the server (30 minutes or so) the socket seems to get closed and the client is unable to get any new data anymore.
My reading thread gets blocked at the read() operation, waiting for new messages and when new data finally arrives it throws a "socket closed" exception.
So my question is: who does the closing? is it normal? I mean, is it for example something that the operating system does (my client is running on Windows XP)? I'm new at socket programming and although I have looked for information about this issue I have found nothing.
To solve the problem if thought about using ping-pong messages but I wonder if there is a better way.
Can anyone help me? Thanks in advance