DatagramSocket IsConnected() Example
Returns the connection state of the socket.
DatagramSocketclass IsConnected() method example. This example shows you how to use IsConnected() method.This method Returns the connection state of the socket.
Here is the code:-
/**
* @Program that Returns the connection state of the socket.
* IsConnected.java
* Author:-RoseIndia Team
* Date:-20-jun-2008
*/
import java.net.*;
public class IsConnected {
public static void main(String[] args) throws Exception {
DatagramSocket ds = new DatagramSocket();
ds.connect(new InetSocketAddress(9090));
System.out.println("Socket succesfuly connected to a server: " + ds.isConnected());
}
} |
Output of the program:-
| Socket succesfuly connected to a server: true |
|