title: Can't Bind to Broadcast Address in Client -- Java/Scala
body: <p>I'm trying to write a simple UDP heartbeat to broadcast to all listening nodes on a given port throughout my subnet.</p>
  
  <p>I'm having trouble creating/binding the client DatagramSocket.  I'm trying code like this:</p>
  
  <pre><code>// My IP is 192.168.201.57, so I'm using 192.168.201.255 for broadcast.  Right?
  val socket = new DatagramSocket(9099, InetAddress.getByName("192.168.201.255"))
  </code></pre>
  
  <p>This produced an exception: java.net.BindException: Can't assign requested address.</p>
  
  <p>I've also tried 255.255.255.255 with the same result. 
  Also tried something like this based on something I read in another post:</p>
  
  <pre><code>val socket = new DatagramSocket(null)
  socket.bind( new InetSocketAddress(broadcastIp, port) )  // where I tried several broadcastIp values
  </code></pre>
  
  <p>This also gave the same exception.  I should also add that I've tried different port values and made sure nothing else on the machine is using the ports I'm trying.</p>