In non-blocking mode, both Solaris and Linux throw
"SocketException: Resource temporarily unavailable"
when attempting to read from a datagram channel
where no datagrams are available.
On Windows (2000/98) receive() returns null per spec.
excerpt:
try {
DatagramChannel socket1 = DatagramChannel.open(5441);
socket1.configureBlocking(false);
ByteBuffer buf1 = ByteBuffer.allocateDirect(256);
// receive request (nothing sent)
SocketAddress sa1 = socket1.receive(buf1);
System.out.println("Good! No Exception thrown");
System.out.println("Value of sa1 = " + sa1);
} catch (Exception e1) {
System.out.println ("Failed - exception thrown = " + e1);
}
Test attached.