0
votes

I am implementing the client server program by using sockets in java. Where I need to check whether client is connected to server in specific amount of time(eg:1 min) or not. If client socket is not connected to the server in time, I need to display the msg as"Server is not able to connect now... Please retry!" to user.

In this scenario I have observed the client scoket is listening for server socket for some default time. So could you please help me how to set the time for client socket waiting for server socket.

Regards mini.

1
This is very unclear. The server socket listens, the client connects. The client does not wait for the server. Please clarify your description.Flavio

1 Answers

1
votes

To check connection timeout use Socket.connect(SocketAddress endpoint, int timeout) To check read time out use Socket.setSoTimeout(int timeout)