This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SocketTimeoutException during serverSocket.accept() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "SocketTimeoutException during serverSocket.accept()" Watch "SocketTimeoutException during serverSocket.accept()" New topic
Author

SocketTimeoutException during serverSocket.accept()

Anton Brass
Greenhorn

Joined: Sep 08, 2010
Posts: 25
Hey,

I want to implement a socket based solution for the UrlyBird project.

Therefore I created following simple server (extends Thread):



Every minute I get a SocketTimeoutException (since timeout is 60000 miliseconds) if no client is connected or the client doesn't send anything.

Should I catch this exception in the while-loop, or is there something generally wrong and such an exception shouldn't occur?

Thanks for your help
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 140

Why do you use the setSoTimeout?
Clients can connect all day when the server is up, so no need to use a time out?


SCJP, SCWCD, SCJD
Anton Brass
Greenhorn

Joined: Sep 08, 2010
Posts: 25
good point, works now without exception.

I'll let the value to 60 seconds and catch the exception, so it is recognizeable if the server hang up.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SocketTimeoutException during serverSocket.accept()
 
Similar Threads
Why should I use a new Socket to interrupt serverSocket.accept() ?
J2se server and J2me client
Socket connection
Networking question
mutiple socket connection issue