title: DatagramSocket never receives
body: <p>Despite me knowing that my UDP packets are arriving as expected (via Wireshark), and having the Windows firewall turned off - my very simple Java code never receives any packets.</p>
  
  <pre><code>byte[] buffer = new byte[2048];
  DatagramSocket socket = new DatagramSocket( 50000 );
  DatagramPacket packet = new DatagramPacket( buffer, buffer.length );
  socket.receive( packet );
  </code></pre>
  
  <p>I have 3 network adapters on my machine, so I tried being very specific about IPs.  I tried setting the socket to look at the local address the packets were arriving on - didn't receive anything.  And I also tried connecting the socket to the remote IP the packets were being sent on - didn't receive anything.  All the while Wireshark is seeing all the 160 packets per second arriving...</p>
  
  <p>My only other thought was that I'm not calculating the UDP checksum on the sending end (the UDP packets are assembled 'by hand' on an embedded system), it is just being set to 0x0000 - does <code>DatagramSocket</code> discard UDP packets without a checksum!?</p>
  
  <hr>
  
  <p>I wrote a simple test server to aid diagnosing the problem per @Andreas' suggestion.</p>
  
  <pre><code>InetAddress outAddr = InetAddress.getLocalHost();
  InetAddress inAddr = InetAddress.getByName( "192.178.178.0" );
  
  byte[] buffer = ( "Hello" ).getBytes();
  DatagramSocket socket = new DatagramSocket( 50000, outAddr );
  while ( true ) {
      DatagramPacket packet = new DatagramPacket( buffer, buffer.length, 
                                                  inAddr, 50000 );
      socket.send( packet );
  
      try {
          Thread.sleep( 500 );
      } catch ( InterruptedException e ) {
          // Ignore.
      }
  }
  </code></pre>
  
  <p>Wireshark dutifully notes that it is receiving them all - but my client still doesn't, even when the receiving IP is explicitly set:</p>
  
  <pre><code>InetAddress inAddr = InetAddress.getByName( "192.178.178.0" );
  DatagramSocket socket = new DatagramSocket( 50000, inAddr );
  ...
  socket.receive( packet );
  </code></pre>
  
  <hr>
  
  <p>Something odd I have just noticed though, when I check which <code>NetworkInterface</code> is being used for sending and receiving, Java reports back the right one (the one 'owning' 192.178.178.0) - but Wireshark only sees my test server packets on a different network device.  Any ideas on what is going on?</p>