DatagramSocket Close() Example
Closes this datagram socket.
DatagramSocketclass Close() method example. This example shows you how to use Close() method.This method Closes this datagram socket.
Here is the code:-
/**
* @Program that Closes this datagram socket.
* Close.java
* Author:-RoseIndia Team
* Date:-20-jun-2008
*/
import java.net.*;
public class Close {
public static void main(String[] args) throws SocketException {
DatagramSocket ds = new DatagramSocket();
// Gets the local address to which the socket is bound.
System.out.println("local address before closing socket: " + ds.getLocalAddress());
//Closes this datagram socket.
ds.close();
System.out.println("local address after closing socket: " + ds.getLocalAddress());
}
} |
Output of the program:-
local address before closing socket: 0.0.0.0/0.0.0.0
local address after closing socket: null |
|