🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #553

Re: UNIX like select() for Java!

#553
From: Chuck McCrobie (** MAD VAX **)
Date: Fri, 19 Dec 1997 00:00
41 lines
3071 bytes
Eric Hodges wrote:
> 
> Mark Frazier wrote:
> >
> > > The xware.net.Selector class provides an event-driven mechanism for
> > > handling input from
> > > multiple sockets. It is ideal for writing server like Java applets or
> > > applications. It can be used
> > > on both the client or server side of your sockets based interface.
> >
> > Thanks for this.
> >
> > However, isn't more "java like" to take the approach of
> > running every socket in a new thread? I've done this in
> > Java servers. You start up a Java server socket, and everytime
> > you get a connection, you run a new thread which is a class
> > that serves only that socket. The code is pretty trivial.
> 
> Yeah, I'm not sure why anyone would want to go back to select().  That
> always seemed like a hack to deal with asynchronous notification in a
> single threaded environment.

Do you have one thread doing the accept, then creating other threads to
handle socket communications?  Check out Comer/Stevens for problems with
this.  Basically, your code may drop a connection request because
starting threads may be too expensive.  Why not have each thread do an
accept request with a monitor thread starting more threads when few are
actually waiting for accepts?

I too find the use of threads for this purpose to be easier in Java, but
one has to watch for thread-safe code, i.e. synchronization issues.

Incidentally, I find the select is a UNIX hack.  The VMS sys$wflor seems
to be a bit cleaner, but the archeciture of the program is roughly the
same as using the select.

Chuck McCrobie (** MAD VAX **)

-- 
ALL OPINIONS DO NOT NECESSARILY REFLECT THOSE OF MY EMPLOYER.
Technical Details
Message-ID: <349A47B3.121631DB@usdesign.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34973C27.759E1BA4@bellatlantic.net> <34984761.369C83CC@rmi.net> <34985E4D.539C@telecheck.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10a146,aee69011bb9ffa08
X-Google-Attributes: gid10a146,public
X-Google-Thread: f5d71,aee69011bb9ffa08
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 107d55,aee69011bb9ffa08
X-Google-Attributes: gid107d55,public
X-Google-Thread: 111d6b,aee69011bb9ffa08
X-Google-Attributes: gid111d6b,public
X-Google-Thread: f4bc9,aee69011bb9ffa08
X-Google-Attributes: gidf4bc9,public
X-Google-Thread: 1291f0,aee69011bb9ffa08
X-Google-Attributes: gid1291f0,public
X-Google-Thread: 1089d0,aee69011bb9ffa08
X-Google-Attributes: gid1089d0,public
X-Google-Thread: 112e38,aee69011bb9ffa08
X-Google-Attributes: gid112e38,public
From: "Chuck McCrobie (** MAD VAX **)" <mccrobie@usdesign.com>
Subject: Re: UNIX like select() for Java!
Date: 1997/12/19
Message-ID: <349A47B3.121631DB@usdesign.com>
X-Deja-AN: 308585986
Content-Transfer-Encoding: 7bit
References: <34973C27.759E1BA4@bellatlantic.net> <34984761.369C83CC@rmi.net> <34985E4D.539C@telecheck.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: U.S. Design
Newsgroups: comp.lang.java,comp.lang.java.misc,comp.lang.java.programmer,comp.lang.java.tech,borland.public.jbuilder.thirdpartytools,borland.public.jbuilder.java.api,symantec.support.devtools.pc.visual-cafe-pro.using,symantec.support.devtools.windows.vcafe4java.Other