MulticastSocket SetInterface() Example

Set the multicast network interface


MulticastSocketclass SetInterface() method example. This example shows you how to use SetInterface() method.This method Set the multicast network interface

Here is the code:-
/* 
 * @Program that Set the multicast network interface
 * SetInterface.java 
 * Author:-RoseIndia Team
 * Date:-27-Jun-2008
 */

import java.net.*;

public class SetInterface {

    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