Java Socket isConnected() method

The isConnected () method of Java Socket class returns the connection state of the socket. This method would continue to return the connection state which was there before being closed.

Syntax

Parameter

NA

Return

The isConnected () method would return a Boolean value 'true' if the socket has been successfully connected to a server.

Example 1

Test it Now

Output:

The socket is connected: true
The socket is bounded: true

Example 2

Test it Now

Output:

The Socket is connected: true
The socket is bounded: true




Latest Courses