Which exception will occur if specified port number is not available for Datagram Societ?
Answers
Answer:
here is your answer hope it helps ☺️
Explanation:
This class represents a socket for sending and receiving datagram packets.
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.
Where possible, a newly constructed DatagramSocket has the SO_BROADCAST socket option enabled so as to allow the transmission of broadcast datagrams. 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.
Since:
JDK1.0
SocketException will occur if the specified port number is not available for Datagram Societ.
- A ServerSocket is for accepting incoming network connections on some stream protocol; e.g. TCP/IP.
- The most common cause of SocketException is reading or writing from or to a closed socket connection.
- It can also occur when the connection is closed before all the data is read in the socket buffer.
- Slow network - A poor network connection might also cause a SocketException.
- Socket timeouts can occur when attempting to connect to a remote server, or during communication, especially long-lived ones.
- They can be caused by any connectivity problem on the network, such as A network partition preventing the two machines from communicating. The remote machine crashing.
#SPJ2