DatagramSocket isClosed() Example
Returns whether the socket is closed or not.
DatagramSocketclass isClosed() method example. This example shows you how to use isClosed() method.This method Returns whether the socket is closed or not.
Here is the code:-
/**
* @Program that Returns whether the socket is closed or not.
* IsClosed.java
* Author:-RoseIndia Team
* Date:-20-jun-2008
*/
import java.net.*;
public class IsClosed {
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
ds.connect(new InetSocketAddress(9090));
System.out.println("The socket is closed :" + ds.isClosed());
}
} |
Output of the program:-
| The socket is closed :false |
|