Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Giovanni Azua Newsgroups: comp.lang.java.programmer Subject: Re: Blocking IO thread-per-connection model: possible to avoid polling? Date: Thu, 29 Sep 2011 22:21:06 +0200 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net utJfE2WXhabrn1sXZK6SWAebzS+NUFvGXmGoAV+7asx/5xThkn Cancel-Lock: sha1:nlGsrrC/YQC6VZ8yxVln9QjoQco= User-Agent: Microsoft-Entourage/12.31.0.110725 Thread-Topic: Blocking IO thread-per-connection model: possible to avoid polling? Thread-Index: Acx+5VEXlJD8rP+K7E+JSs/dOy8NXQ== Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8402 Hi Peter, On 9/27/11 6:29 PM, in article wrote: > I agree that the documentation is not clear on this point. However, it > is a fundamental criteria for BSD sockets and any API inherited from > them that sockets be thread-safe and full duplex. Java sockets are the > same. > > You would not want to use the same InputStream simultaneously from > multiple threads, nor the same OutputStream simultaneously from multiple > threads, but reading from one thread and writing from another is fully > supported. The Java sockets API would be broken if it weren't. > Thank you! Yes I found about full-duplex supported by Java Sockets after researching a bit :) I finished creating the remoting support for my project based on the "one-thread-per-connection" model. Actually, in order to have a stable and predictable middleware load we were strongly advised to write blocking Clients (send request and wait for response) so things got real simple as only one Thread per connection is needed in the Middleware side: read request, block until it is processed, and send back response. A very tricky part was to Unit tests the whole remoting solution .. sigh. I will be doing the NIO version soon. Best regards, Giovanni PS: thank you all for the help on these questions ... your answers were pretty enlightening.