You're setting a ten second timeout on the server socket.
The accept()
method will therefore throw a SocketTimeoutException
if no connection arrives within ten seconds.
If you don't want that behaviour, don't set the timeout, or raise it.
I have no idea why you're surprised at getting a timeout when you're setting it yourself.
NB It is utterly pointless to call setReuseAddress()
on the server socket after it is bound, let alone every time you accept a new connection.