All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.net.MulticastSocket

java.lang.Object
   |
   +----java.net.DatagramSocket
           |
           +----java.net.MulticastSocket

public final class MulticastSocket
extends DatagramSocket
The multicast datagram socket class is useful for sending and receiving IP multicast. Currently applets are not allowed ot use multicast sockets.


Constructor Index

 o MulticastSocket()
Create a multicast socket.
 o MulticastSocket(int)
Create a multicast socket and bind it to a specific port.

Method Index

 o getInterface()
Retrieve the address of the network interface used for multicast packets.
 o joinGroup(InetAddress)
Joins a multicast group.
 o leaveGroup(InetAddress)
Leave a multicast group.
 o send(DatagramPacket, byte)
Sends a datagram packet to the destination
 o setInterface(InetAddress)
Set the outgoing network interface for multicast packets on this socket, to other than the system default.

Constructors

 o MulticastSocket
  public MulticastSocket() throws IOException
Create a multicast socket.

 o MulticastSocket
  public MulticastSocket(int port) throws IOException
Create a multicast socket and bind it to a specific port.

Parameters:
local - port to use

Methods

 o joinGroup
  public void joinGroup(InetAddress mcastaddr) throws IOException
Joins a multicast group.

Parameters:
mcastaddr - is the multicast address to join
Throws: IOException
is raised if there is an error joining or when address is not a multicast address.
 o leaveGroup
  public void leaveGroup(InetAddress mcastaddr) throws IOException
Leave a multicast group.

Parameters:
mcastaddr - is the multicast address to leave
Throws: IOException
is raised if there is an error leaving or when address is not a multicast address.
 o setInterface
  public void setInterface(InetAddress inf) throws SocketException
Set the outgoing network interface for multicast packets on this socket, to other than the system default. Useful for multihomed hosts.

 o getInterface
  public InetAddress getInterface() throws SocketException
Retrieve the address of the network interface used for multicast packets.

 o send
  public synchronized void send(DatagramPacket p,
                                byte ttl) throws IOException
Sends a datagram packet to the destination

Parameters:
p - is the packet to be sent. The packet should contain the destination multicast ip address and the data to be sent. One does not need to be the member of the group to send packets to a destination multicast address.
ttl - optional time to live for multicast packet. default ttl is 1.
Throws: IOException
is raised if an error occurs i.e error while setting ttl.
See Also:
send, receive

All Packages  Class Hierarchy  This Package  Previous  Next  Index