The Artima Developer Community
Sponsored Link

Java Answers Forum
Socket timeout

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Cindy Sue

Posts: 1
Nickname: cindysue
Registered: Feb, 2006

Socket timeout Posted: Feb 13, 2006 1:10 PM
Reply to this message Reply
Advertisement
We have a data client and server. The server periodically
gets restarted, and the client needs to be able to detect
that the server is no longer alive. The server sending a
shutdown notice/command is not an option.

What I have been doing the client is this:

Socket socket = new Socket(host, port)
socket.setSoTimout(30000); // 30 seconds
InputStreamReader reader = socket.getInputStream();
while(flag) {
try {
char c = reader.read();
<stuff>
}
catch(SocketTimeoutException e) {
<stuff>
}
}

Problem is, instead of a SocketTimeoutException
after 30 seconds, after *maybe* 2 minutes I'll get
an IOException. Can anyone please help me?

Topic: Problem with AWT and Unicode Previous Topic   Next Topic Topic: your advices

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use