MulticastSocket GetInterface() Example

Returns An InetAddress representing the address of the network interface


MulticastSocketclass GetInterface() method example. This example shows you how to use GetInterface() method.This method Returns An InetAddress representing the address of the network interface

Here is the code:-
/* 
 * @Program that Retrieve the address of the network interface. 
 * GetInterface.java 
 * Author:-RoseIndia Team
 * Date:-27-Jun-2008
 */

import java.net.*;

public class GetInterface {

    public static void main(String[] argsthrows Exception {
        SocketAddress sa = new InetSocketAddress(8080);
        MulticastSocket ms = new MulticastSocket(sa);
        //Specify the network interface for outgoing multicast datagrams sent
        ms.setInterface(InetAddress.getByName("localhost"));
        //Retrieve the address of the network interface. 
        System.out.println("Address of the network interface is: "
                +ms.getInterface());



    }
}

Output of the program:-
 Address of the network interface is: localhost/127.0.0.1

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

HOME | COPYRIGHT | CONTACT US