Pb. receiving UDP datagrams
Hi,
I receive a continuous flow of UDP datagrams on my PC that I would like
to process in a Java program. I wrote the following piece of code but I
can't get any datagram (the .receive() function blocks forever). I
checked with a network sniffer - Ethereal/WireShark - and I could
verify the presence of a continuous UDP flow with valid UDP datagram
headers (destination port: 8081; checksum = 0 (none)).
Could someone help me finding out what I'm doint wrong?
Eric
PS: The piece of code:
public final class UDPClient {
private static final Logger logger = Logger.getRootLogger();
static byte[] buffer = new byte[65507];
public static void main(String[] args) {
try {
DatagramSocket ds;
ds = new DatagramSocket(8081);
DatagramPacket dpi;
dpi = new DatagramPacket(new byte[512], 512);
while(true) {
ds.receive(dpi);
logger.info("UDP datagram received from " +
dpi.getAddress() + ":" + dpi.getPort());
}
} // end try
catch (Exception e) {
System.err.println(e);
} // end catch
}
}