Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Socket closed after a time with no activity

843790Apr 25 2007 — edited May 2 2007
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2007
Added on Apr 25 2007
6 comments
797 views