DatagramSocket Disconnect() Example

Disconnects the socket.


DatagramSocketclass Disconnect() method example. This example shows you how to use Disconnect() method.This method Disconnects the socket.

Here is the code:-

/**
 * @Program that Disconnects the socket.
 * DisConnect.java 
 * Author:-RoseIndia Team
 * Date:-20-jun-2008
 */
import java.net.*;

public class Disconnect {

    public static void main(String[] argsthrows Exception {
        DatagramSocket ds = new DatagramSocket();
        SocketAddress s = new InetSocketAddress("girish-desktop"8089);
        System.out.println("Remote socket address: " + ds.getInetAddress());
        //Connects this socket to a remote socket address .
        ds.connect(s);
        System.out.println(ds.getInetAddress());
        // Disconnects the socket.
        ds.disconnect();
        System.out.println(ds.getInetAddress());

    }
}

Output of the program:-
 Remote socket address: null
girish-desktop/127.0.1.1
null

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US