Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Channel Switch in GO, can I do this with java.nio Date: Tue, 18 Oct 2011 09:16:47 +0200 Organization: albasani.net Lines: 40 Message-ID: References: <8140673.542.1318892303608.JavaMail.geo-discussion-forums@prfk19> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 7557YOB1kYPRukvhmM7EbCCQwWtr6cVbbmXlMBD0MxQ9XU6CowvCkGXdbbsRGWRtabYAz+S3Vhduqo/dKMVErvHFe7QiSUmPERso7HksNg50KNklt74fcH327BvSMa9G NNTP-Posting-Date: Tue, 18 Oct 2011 07:16:48 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="Nn5RCXcdVkMT5+Xd9viVKY+yqTzR6WPeWtlWS+gJD/99fTQTNU0DrgUFS4HpwdfIfcXZ7N1FCMO1kNxpZqqRrD/FAgNjrVCrJ+wWpzsCzQaslt69nZ3aFxZH/voVtLnT"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 In-Reply-To: Cancel-Lock: sha1:EObSTHLKDIA7AFxQc+F+4QBGcy4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8941 markspace schrieb: > I like this article. It's old, but since NIO was new when the article > was written, it explains the basics without trying to do anything fancy. > It seem pretty close to the information I have in my book. > > > > Thanks for the reference, very helpful. P.S.: Just out of habit I would code: if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT) { // Accept the new connection // ... } With a different check: if ((key.readyOps() & SelectionKey.OP_ACCEPT) != 0) { // Accept the new connection // ... } The same check is also used in the definition of the method isAcceptable(), so it could be also coded as: if (key.isAcceptable()) { // Accept the new connection // ... }