hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Berlin" <sber...@limepeer.com>
Subject RE: HLCA: client vs server
Date Wed, 19 Jan 2005 04:30:35 GMT
> Ideally a single blocking operation that returned when the next request
> is available would be best.  My knowledge of NIO is pretty minimal, but
> it seems like this should be an option.

I haven't followed the conversation fully, so my answer may have already
been covered...  but yes, what you're looking for exists.  You must use the
"nio" package that's new in Java 1.4.  Specifically, the 'Selector' object (
http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/Selector.html )
handles waiting until an event is available.

Here's a quick example I found that illustrates using a non-blocking
ServerSocket and accepting connections.
http://javaalmanac.com/egs/java.nio/NbServer.html  

Here's another good article on NIO:
http://www.onjava.com/pub/a/onjava/2004/09/01/nio.html .

Using NIO involves more or a less a complete rewrite of any legacy I/O code
if you want to be at all efficient.  NIO makes use of 'Buffer' classes
instead of InputStream/OutputStream, among many other changes to threading
architectures, etc...

A fellow by the name of Roger Kapsi contributed a 'DAAP' (Digital Audio
Access Protocol) package to LimeWire that has a good abstraction for using
blocking or non-blocking code.  If you like, it's available online at
http://limewire.org/fisheye/viewrep/misc/daap , or can be checked out of our
CVS using :pserver:guest@limewire.org:/cvs (password guest), and checking
out the 'daap' module.

Thanks,
 Sam


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Mime
View raw message