Articles
|
News
|
Weblogs
|
Books
|
Forums
Artima Forums
|
Articles
|
Weblogs
|
Java Answers
|
News
Sponsored Link
•
Java Answers Forum
Socket timeout
0
replies on
1
page.
Welcome
Guest
Sign In
Back to Topic List
Reply to this Topic
Search Forum
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
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?
Previous Topic
Next Topic
Sponsored Links
Web
Artima.com
Copyright
© 1996-2019 Artima, Inc. All Rights Reserved. -
Privacy Policy
-
Terms of Use