The read methods defined by DatagramChannel inherit javadoc from ReadableByteChannel that specifies that -1 is returned when the channel is at EOF. There is no concept of EOF in DatagramChannel. However, they do return -1 when a zero-length datagram is received. This is long standing and unspecified behavior that, by accident, allows a caller to distinguish it from the non-blocking case where there are datagrams available.
- duplicates
-
JDK-8237522 (dc) DatagramChannel issues with zero-length datagrams
-
- Open
-
- relates to
-
JDK-8237522 (dc) DatagramChannel issues with zero-length datagrams
-
- Open
-
- links to