java.net.MulticastSocket
java.net.DatagramSocket
None
None
New as of JDK 1.1
The MulticastSocket class implements packet-oriented, connectionless, multicast data communication. In Internet parlance, this is the User Datagram Protocol (UDP) with additional functionality for joining and leaving groups of other multicast hosts on the Internet. A multicast group is specified by a Class D address, which means that the four highest-order bits are set to 1110. In other words, multicast addresses are in the range 224.0.0.1 through 239.255.255.255 inclusive.
MulticastSocket inherits most of its functionality from DatagramSocket; it adds the ability to join and leave multicast groups. When a MulticastSocket joins a group, it receives all of the packets destined for the group. Any DatagramSocket or MulticastSocket can send packets to a multicast group.
public final class java.net.MulticastSocket extends java.net.DatagramSocket { // Constructors public MulticastSocket(); public MulticastSocket(int port); // Instance Methods public InetAddress getInterface(); public byte getTTL(); public void joinGroup(InetAddress mcastaddr); public void leaveGroup(InetAddress mcastaddr) public synchronized void send(DatagramPacket p, byte ttl); public void setInterface(InetAddress inf); public void setTTL(byte ttl); }
If any kind of I/O error occurs.
If the application is not allowed to listen on the port.
This constructor creates a MulticastSocket that is bound to any available port on the local host machine.
A port number.
If any kind of I/O error occurs.
If the application is not allowed to listen on the given port.
This constructor creates a MulticastSocket that is bound to the given port on the local host machine.
The address of the network interface used for outgoing multicast packets.
If any kind of socket error occurs.
This method returns the IP address that this MulticastSocket uses to send out packets to multicast destinations.
The time-to-live (TTL) value for this socket.
If any kind of I/O error occurs.
This method returns the TTL value for this socket. This value is the number of hops an outgoing packet can traverse before it is discarded.
The IP address of the group to join.
If any kind of I/O error occurs.
If the application is not allowed to access the given multicast address.
This method is used to join a multicast group. An exception is thrown if the given address is not a multicast address. While the socket is part of a group, it receives all the packets that are sent to the group.
The IP address of the group to leave.
If any kind of I/O error occurs.
If the application is not allowed to access the given multicast address.
This method is used to leave a multicast group. An exception is thrown if the given address is not a multicast address.
public synchronized void send(DatagramPacket p, byte ttl) throws IOException
The DatagramPacket to be sent.
The time-to-live (TTL) value for this packet.
If any kind of I/O error occurs.
If the application is not allowed to send data to the packet's destination.
This method sends a packet from this socket using the given TTL value. The packet data, packet length, destination address, and destination port number are specified by the given DatagramPacket.
Generally, it is easier to use setTTL() to set the TTL value for the socket, then use send(DatagramPacket) to send data. This method is provided for special cases.
The new address of the network interface for multicast packets.
If any kind of socket error occurs.
This method is used to set the address that is used for outgoing multicast packets.
The new time-to-live (TTL) value for this socket.
If any kind of I/O error occurs.
This method is used to set the TTL value of the socket. The TTL value is the number of hops an outgoing packet can traverse before it is discarded.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
close() |
DatagramSocket |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
getLocalAddress() |
DatagramSocket |
getLocalPort() |
DatagramSocket |
getSoTimeout() |
DatagramSocket |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
receive(DatagramPacket) |
DatagramSocket |
send(DatagramPacket) |
DatagramSocket |
setSoTimeout(int) |
DatagramSocket |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
DatagramPacket, DatagramSocket, DatagramSocketImpl, InetAddress, IOException, SecurityException, SocketException
This HTML Help has been published using the chm2web software. |