Re: Java NIO: calling selector.select() before socketChannel.write()

Bob Lee <[email protected]> Wed, 16 Apr 2008 08:03:32 -0700
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Yeah, you use a selector when you want to deal with multiple streams from a
single thread, the idea being that threads don't scale well enough to
support tens of thousands of connections. TheServerSide recently had an
article that claimed that thread impls have gotten efficient enough that yo=
u
may be better off using blocking I/O. I would test it.

Bob

On Wed, Apr 16, 2008 at 12:22 AM, Avinash Lakshman <[email protected]>
wrote:

> There is no reason to do a select() before a write(). However when you do
> perform a write() you may not write the entire set of bytes you want to
> write. In that event you want to register for OP_WRITE interest with the
> selector and when notified by the selector (when the socket is writeable)
> push the remaining bytes out.
>
> Cheers
> A> Date: Tue, 15 Apr 2008 16:48:50 -0700> From: [email protected]>
> Subject: Re: [ADVANCED-JAVA] Java NIO: calling selector.select() before
> socketChannel.write()> To: [email protected]> > I've neve=
r
> used Java's non-blocking I/O, but in POSIX non-blocking I/O, you> typical=
ly
> use one select() for everything.> > Bob> > On Tue, Apr 15, 2008 at 4:27 P=
M,
> Sergey Marakhov <[email protected]>> wrote:> > > Hi all.> >> > I'=
m
> looking at ways to simplify our current implementation of socket> >
> communications between an agent and multiple clients. There is a client> =
>
> connection object created per connected client, client connection is> >
> passed through an "incoming" selector and each client connection opens it=
s>
> > own outgoing selector. So, question 1: do I need to create separate> >
> outgoing selectors, or is using a single selector for both in and out> >
> operations is the way to go?> >> > Next, before each invocation of
> socketChannel.write(=85) method, we do> > outgoingSelector.select(). Is i=
t
> necessary to do select() before write> > operations?> >> > Our knowledge =
of
> NIO is rather limited, hence all this questions.> >> > Much appreciated=
=85> >
> Sergey> >> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> > This list is hosted by
> DevelopMentor(R) http://www.develop.com> >> > View archives and manage
> your subscription(s) at> > http://discuss.develop.com> >> >
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> This list is hosted by DevelopMentor(R)
> http://www.develop.com> > View archives and manage your subscription(s) a=
t
> http://discuss.develop.com
> _________________________________________________________________
> Pack up or back up=96use SkyDrive to transfer files or keep extra copies.
> Learn how.
>
> http://www.windowslive.com/skydrive/overview.html?ocid=3DTXT_TAGLM_WL_Ref=
resh_skydrive_packup_042008
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> This list is hosted by DevelopMentor(R)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com