A datagram socket is the sending or receiving point for a packet delivery service. Each packet sent or received on a datagram socket is individually addressed and routed. Multiple packets sent from one machine to another may be routed differently, and may arrive in any order.
UDP broadcasts sends are always enabled on a DatagramSocket. In order to receive broadcast packets a DatagramSocket should be bound to the wildcard address. In some implementations, broadcast packets may also be received when a DatagramSocket is bound to a more specific address.
Example: DatagramSocket s = new DatagramSocket(null); s.bind(new InetSocketAddress(8888));
Which is equivalent to: DatagramSocket s = new DatagramSocket(8888);
Both cases will create a DatagramSocket able to receive broadcasts on UDP port 8888.
@author Pavani Diwanji
@version 1.101, 06/08/06
@see java.net.DatagramPacket
@see java.nio.channels.DatagramChannel
@since JDK1.0
|
|
|
|