[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-nio-discuss
Subject:    AsynchronousCharChannel
From:       Alan.Bateman () Sun ! COM (Alan Bateman)
Date:       2009-07-03 7:59:13
Message-ID: 4A4DBA51.9080107 () sun ! com
[Download RAW message or body]

Gili wrote:
> Alan Bateman (via Nabble) wrote:
> > I haven't had a chance to look at this in any detail but I wonder if 
> you
> > really need write(... boolean endOfInput)? That is, do you really need
> > the equivalent of a half-close (as in TCP) or isn't close sufficient?
>
>         Actually, I just realized... what happens if the last write() 
> triggers
> a flush() that just so happens to trigger the remote end sending bytes
> back? If close() means flushes the output, then the receiving end never
> has a chance of picking up those last incoming bytes. Is this a
> reasonable use-case?
Yep, close is complicated. Your filter will probably need a timer so 
that if close initiates a write then the timer can be used to close the 
wrapped channel if the write doesn't complete within a reasonable time. 
You'll probably need this anyway, even if you have the equivalent of 
shutdownOutput. Issues such as the peer sending data at around the time 
that you close the channel are of course possible, and likely indicate a 
protocol issue. On the "receiving end" attempts to read from the channel 
will fail with ClosedChannelException (as you would expect).

-Alan.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic