How to read 1 bit from udp packet
<p>I want to read 1 bit from a udp packet.</p>

<p>The udp packet looks like this (c code):</p>

<pre class="lang-c prettyprint-override"><code>struct typedef struct s_foo
{
   __u32 foo;
   __u8  bar:1,
         bob:1;
} __attribute__((packed)) s_foo;
</code></pre>

<p>How in java can i read this?</p>

<p>So far I have this but i can't read foo nor bar or bob...</p>

<pre class="lang-java prettyprint-override"><code>import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class BroadcastListener
{
    public static void main(String[] args) throws IOException
    {
        if (args.length != 1) {
            System.out.println("usage: &lt;program&gt; port");
            System.exit(1);
        }

        int port = Integer.parseInt(args[0]);
        DatagramSocket dgram = new DatagramSocket(port);

        byte[] buffer = new byte[2048];
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);

        while (true) {
            dgram.receive(packet);

            String msg = new String(buffer, 0, packet.getLength());

            System.out.println(packet.getAddress().getHostName() + ": "
                    + msg);

            packet.setLength(buffer.length);
        }
    }
}
</code></pre>
