This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Detecting remote NIO sockets closed


Stanley Brown wrote:
> Found another NIO sockets issue.  For some reason an OP_READ event is 
> never issued when a non-blocking socket has concluded.  This is a 
> problem because, from my understanding, the only way to know you've 
> reached the end of one of these is by recieving an OP_READ and getting a 
> -1 back when attempting to read from the channel. 
> 
> Example:  http://javaalmanac.com/egs/java.nio/DetectClosed.html
> 
> I dug around a bit and I think that the problem resides in 
> natSelectorImplWin32.cc:
> 
>     aArray[nCurIndex++].init(pReadFD[i], FD_ACCEPT | FD_READ);
> 
> Shouldnt we take interest in closing fd's?
> 
>     aArray[nCurIndex++].init(pReadFD[i], FD_ACCEPT | FD_READ | FD_CLOSE);

It may be that there is an error in libgcj, but the article you refer to
contains incorrect information.

Reads are usless for detecting connections that have not terminated
"normally".  Doing a write is the only reliable method for determining that
a connection is still "open".

David Daney.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]