-1 and orderly socket shutdown
Leon Finker
leonfin at optonline.net
Wed Apr 22 13:11:03 PDT 2009
I was referring to AsynchronousSocketChannel. But I guess it's to keep it
the same as SocketChannel. In AsynchronousSocketChannel one would not get 0
bytes read for tcp, correct? One can get 0 bytes for udp.
-----Original Message-----
From: Alan.Bateman at Sun.COM [mailto:Alan.Bateman at Sun.COM]
Sent: Wednesday, April 22, 2009 3:56 PM
To: Leon Finker
Cc: nio-discuss at openjdk.java.net
Subject: Re: -1 and orderly socket shutdown
Leon Finker wrote:
>
> Is there a reason that result of -1 is used instead of somewhat
> universal 0 for detecting graceful shutdown on recv side for sockets?
> Thanks!
>
EOF can't be indicated by 0 as otherwise you couldn't distinguish it
from cases where zero bytes are read (say a SocketChannel configured in
non-blocking mode).
-Alan.
More information about the nio-discuss
mailing list