Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 9710 invoked from network); 1 Nov 2004 02:54:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Nov 2004 02:54:40 -0000 Received: (qmail 61148 invoked by uid 500); 1 Nov 2004 02:54:30 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 61031 invoked by uid 500); 1 Nov 2004 02:54:29 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 61016 invoked by uid 99); 1 Nov 2004 02:54:29 -0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,HTML_20_30,HTML_MESSAGE,HTML_TITLE_EMPTY X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [24.71.223.10] (HELO pd2mo3so.prod.shaw.ca) (24.71.223.10) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 31 Oct 2004 18:54:27 -0800 Received: from pd5mr7so.prod.shaw.ca (pd5mr7so-qfe3.prod.shaw.ca [10.0.141.183]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0I6H009W1C2QTG60@l-daemon> for dev@geronimo.apache.org; Sun, 31 Oct 2004 19:54:26 -0700 (MST) Received: from pn2ml5so.prod.shaw.ca ([10.0.121.149]) by pd5mr7so.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0I6H004FEC2QJZ20@pd5mr7so.prod.shaw.ca> for dev@geronimo.apache.org; Sun, 31 Oct 2004 19:54:26 -0700 (MST) Received: from shaw.ca (S01060050046eee7b.vn.shawcable.net [24.80.91.129]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0I6H00E3EC2OIR@l-daemon> for dev@geronimo.apache.org; Sun, 31 Oct 2004 19:54:26 -0700 (MST) Date: Sun, 31 Oct 2004 19:54:25 -0800 From: Craig Johannsen Subject: Re: Weird build errors on SuSE 9.2 In-reply-to: To: dev@geronimo.apache.org Message-id: <4185B371.1010700@shaw.ca> MIME-version: 1.0 Content-type: multipart/alternative; boundary=------------020804050503020103070509 X-Accept-Language: en-us, en References: <418500AD.7060102@gluecode.com> <418568A8.2010400@shaw.ca> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------020804050503020103070509 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi Aaron, My environment is Mandrake Linux 9.1, kernel 2.4.2-0.13, libc-2.3.1, 651 MHz Pentium III (Coppermine), and KDE shell. I tested your code with J2SDK 1.4.2_03-b02, mixed mode, and JDK 1.5.0-rc-b63, mixed mode, sharing. In each case the socket timeout didn't work using ssc.accept(). It would wait indefinately, just as the ServerSocketChannel.accept() API documentation says it will: " If this channel is in non-blocking mode then this method will immediately return null if there are no pending connections. Otherwise it will block indefinitely until a new connection is available or an I/O error occurs." The ServerSocket.accept() API documentation erroneously says: "Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made." However, at least it also says it may throw: "SocketTimeoutException - if a timeout was previously set with setSoTimeout and the timeout has been reached." So, the behaviour is mostly following the documentation, though I would like to see ServerSocketChannel.accept() pay attention to the timeout setting. I can't think of any reason it shouldn't. Probably it's a bug, but maybe a bug in the spec, assuming the API docs are correct. Unfortunately, if you use ServerSocket instead of ServerSocketChannel, you lose all those nifty ByteBuffer operations. So, maybe it is a big change and much less efficient to use input and output streams rather than ByteBuffers. Cheers, Craig Aaron Mulder wrote: >On Sun, 31 Oct 2004, Aaron Mulder wrote: > > >> Right. The question is, are we willing to change our code to >>accomodate a bug that, so far, only I am running into? :) I sent bug >>reports to Sun and SuSE, but I suspect they'll go to the great bit bucket >>in the sky, since SuSE 9.2 isn't a supported platform for Sun, and I doubt >>SuSE cares that much about JDK problems. >> >> Though, I guess I should ask, how were you able to duplicate the >>problem? Do you also have a SuSE 9.2 machine, or did you do it on some >>other platform/kernel? >> >>Thanks, >> Aaron >> >>On Sun, 31 Oct 2004, Craig Johannsen wrote: >> >> >>>Hi Aaron, >>> >>>"ssc.socket().accept()" throws a SocketTimeoutException, while >>>"ssc.accept()" does not. One would think that they would have identical >>>behaviour, but apparently not. Here's an example where the socket >>>timeout works with both JDK 1.4.2_03 and JDK 1.5. >>> >>>Cheers, >>>Craig >>> >>>import java.io.IOException; >>>import java.net.*; >>>import java.nio.channels.*; >>> >>>// This code hangs on some Linux systems. >>>public class Hang { >>>public static void main(String[] args) { >>>try { >>>ServerSocketChannel ssc = ServerSocketChannel.open(); >>>ssc.configureBlocking(true); >>>ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), >>>2010),50); >>>ssc.socket().setSoTimeout(5000); >>>System.out.println("accepting..."); >>>ssc.socket().accept(); >>>} catch (IOException e) { >>>e.printStackTrace(); >>>} >>>System.out.println("Finished"); >>>} >>>} >>> >>> >>> > --------------020804050503020103070509 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi Aaron,

My environment is Mandrake Linux 9.1, kernel 2.4.2-0.13, libc-2.3.1, 651 MHz Pentium III (Coppermine), and KDE shell.  I tested your code with J2SDK 1.4.2_03-b02, mixed mode, and JDK 1.5.0-rc-b63, mixed mode, sharing.  In each case the socket timeout didn't work using ssc.accept().  It would wait indefinately, just as the ServerSocketChannel.accept() API documentation says it will: " If this channel is in non-blocking mode then this method will immediately return null if there are no pending connections. Otherwise it will block indefinitely until a new connection is available or an I/O error occurs."  The ServerSocket.accept() API documentation erroneously says: "Listens for a connection to be made to this socket and accepts it. The method blocks until a connection is made."   However, at least it also says it may throw: "SocketTimeoutException - if a timeout was previously set with setSoTimeout and the timeout has been reached."  So, the behaviour is mostly following the documentation, though I would like to see ServerSocketChannel.accept() pay attention to the timeout setting.  I can't think of any reason it shouldn't.  Probably it's a bug, but maybe a bug in the spec, assuming the API docs are correct.

Unfortunately, if you use ServerSocket instead of ServerSocketChannel, you lose all those nifty ByteBuffer operations.  So, maybe it is a big change and much less efficient to use input and output streams rather than ByteBuffers.

Cheers,
Craig


Aaron Mulder wrote:
On Sun, 31 Oct 2004, Aaron Mulder wrote:
  
	Right.  The question is, are we willing to change our code to 
accomodate a bug that, so far, only I am running into?  :)  I sent bug 
reports to Sun and SuSE, but I suspect they'll go to the great bit bucket 
in the sky, since SuSE 9.2 isn't a supported platform for Sun, and I doubt 
SuSE cares that much about JDK problems.

	Though, I guess I should ask, how were you able to duplicate the 
problem?  Do you also have a SuSE 9.2 machine, or did you do it on some 
other platform/kernel?

Thanks,
	Aaron

On Sun, 31 Oct 2004, Craig Johannsen wrote:
    
Hi Aaron,

"ssc.socket().accept()" throws a SocketTimeoutException, while 
"ssc.accept()" does not. One would think that they would have identical 
behaviour, but apparently not. Here's an example where the socket 
timeout works with both JDK 1.4.2_03 and JDK 1.5.

Cheers,
Craig

import java.io.IOException;
import java.net.*;
import java.nio.channels.*;

// This code hangs on some Linux systems.
public class Hang {
public static void main(String[] args) {
try {
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(true);
ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), 
2010),50);
ssc.socket().setSoTimeout(5000);
System.out.println("accepting...");
ssc.socket().accept();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Finished");
}
}

      

--------------020804050503020103070509--