Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] WebSocket + Async Read/Write

Yeah, I have to be able to tell jetty to stop reading data.  If the place I'm sending the data to not accepting any more, and I can't tell jetty to stop sending me data, and I can't block, then I have to buffer it in memory and that solution does not work too well :)

AIO style writes would be good. But I still need to be able to suspend receiving data.

On Tue, Feb 14, 2012 at 9:16 AM, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:
Hi,

On Tue, Feb 14, 2012 at 00:03, Hiram Chirino <hiram@xxxxxxxxxxxxxxxx> wrote:
>
> Oh yeah and for the send side, what would work is if you have a non-blocking version of connection.sendMessage(..., Runnable onComplete) which just appends a Runnable object to the end of the call.  Calling that should just buffer any data that does not fit in the socket write, and once the socket write does finally complete the onComplete runnable should get called.
>

Sure, this is pretty much like JDK 7's Async IO.
It's a pain to program (anonymous classes all over, non sequential
program flow, etc.), but we can support it.
Can you please file a Bugzilla about ?
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Jetty

For the read side, perhaps I was unclear. If the sender is slow, then
we will read as much as we can non blocking, and parse that.
If it's an incomplete frame, we buffer that and do not call the
application, and we release the thread, NIO style.
When more data is available, we read more, parse more, and if the
frame is now complete we call the application.
So if the application is not blocking, reading is already asynchronous
in the NIO sense in Jetty: no threads blocked, etc.

What an application cannot do is to tell Jetty to stop reading.
If the application is notified about a websocket frame, there is no
way for the application to tell Jetty to not read more if there is
data available.
I doubt this is a problem for you, but voice back if it is.

So I am guessing that with JDK7's AIO style of writes for websocket,
you should be good ?

Simon
--
http://cometd.org
http://intalio.com
http://bordet.blogspot.com
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--

Hiram Chirino

Software Fellow | FuseSource Corp.

chirino@xxxxxxxxxxxxxx | fusesource.com

skype: hiramchirino | twitter: @hiramchirino

blog: Hiram Chirino's Bit Mojo





Back to the top