Reputation: 1040
Is it possible to bind a DatagramSocket in java to a specific InetAddress but let choose the system the port, like it is done when calling the DatagramSocket()
constructor?
Upvotes: 0
Views: 68
Reputation: 18855
You have to put 0
as port
number to InetSocketAddress
constructor. You can then get real port number by calling getLocalAddress()
or getLocalPort
.
Upvotes: 2