T
T
thatmaniscool2018-10-29 18:54:55
Java
thatmaniscool, 2018-10-29 18:54:55

How to set connection timeout to server, socket, java?

There is a client, everything connects, but if the server is turned off or the IP address has changed, it sees it waiting indefinitely. How to set the time to wait for a response from the server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-10-29
@thatmaniscool

From documentation :
Connects this socket to the server with a specified timeout value. A timeout of zero is interpreted as an infinite timeout. The connection will then block until established or an error occurs.
endpoint - the SocketAddress
timeout - the timeout value to be used in milliseconds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question