JDK-4212324 : Packets sent to broadcast address not received on servers bound to specific addr
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.1.6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1999-02-17
  • Updated: 2017-08-04
Related Reports
Relates :  
Description
Name: dbT83986			Date: 02/17/99


UDP broadcasts are not received on binding to specific interface 
under Solaris 2.5 & 2.6. The broadcast packets are received under
Windows 95 and Windows NT 4.0.
Background:
  A DHCP server needs to detect which interface it has received
a request from (to be able to allocate an address on the same
net). Since java.net does not provide a way to detect the destination
address a UDP packet was sent to, we opted for a work around by
binding to all the addresses of the server and using the receiving
thread to identify the source interface.
This works fine on Windows.
However on Solaris the server does not receive broadcasted requests.
The DHCP server needs to receive these since initial requests
from DHCP clients are broadcasts.
(Review ID: 48935)
======================================================================

Comments
to receive datagram packets sent to a broadcast IP address, typically an application needs to bind to a wildcard IP address. In terms of DHCP scenario alluded to above, broadcast is releavnt for IPv4, but for IPv6 then multicast is appropriate afaik, there is no functionality at the native level that a provides the proposed information, so as to determine to which address a datagram was sent, when a socket is bound to a wildcard address in a multihomed environment. The only possibility is the src address via recvfrom or recvmsg, but even that will not give sufficient address information to correlate the destination address thus it is impossible to provide the proposed API addition in Java The version stated above is 1.1.6!! The implications are this is IPv4 only, so address any of the issue a more complete IP perspective is required. based on age and java version, one would think it is appropriate to close this jobby?
26-07-2017

EVALUATION We will add an api in jdk7 to DatagramPacket (probably) to provide access to the destination address, when it is available. It will not be available on some operating systems (older windows pre XP)
20-09-2006

EVALUATION The fact that you don't receive broadcasts when the UDP socket is bound to a specific address is normal. That's the defacto behavior for UDP sockets ever since BSD. Win32 takes a stance that diverges from the standard, as usual. To get broadcasts you have to bind the socket to the wildcard address (see bugId 4191980). Problem is: how can you determine where a broadcast came from when you have more than one interface. On Solaris & Linux you need to use the recvmsg() system call instead of recvfrom(). This provides you with a lot more information. Of course this system call doesn't exist on Win32. So, right now, there is nothing much we can do about this. But we should re-evaluate this for the "tiger" timeframe as it is a desirable feature. jean-christophe.collet@Eng 2001-01-30
30-01-2001