From owner-freebsd-java Mon Feb 23 19:57:48 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA00161 for freebsd-java-outgoing; Mon, 23 Feb 1998 19:57:48 -0800 (PST) (envelope-from owner-freebsd-java@FreeBSD.ORG) Received: from teel.info-noire.com (XP11-1-2-15.interlinx.qc.ca [207.253.79.55]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA00149; Mon, 23 Feb 1998 19:57:41 -0800 (PST) (envelope-from alex@gel.usherb.ca) Received: from localhost (alex@localhost) by teel.info-noire.com (8.8.8/8.8.8) with SMTP id VAA04970; Mon, 23 Feb 1998 21:13:57 -0500 (EST) (envelope-from alex@teel.info-noire.com) Date: Mon, 23 Feb 1998 21:13:57 -0500 (EST) From: Alex Boisvert Reply-To: boia01@gel.usherb.ca To: Iyer Mahadevan cc: java@FreeBSD.ORG, saurabh@internetdevices.com, freebsd-java@FreeBSD.ORG, java-port@FreeBSD.ORG Subject: Re: Socket IO problems using Java Sockets on FreeBSD In-Reply-To: <34F1F777.BEC2F180@internetdevices.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, 23 Feb 1998, Iyer Mahadevan wrote: > I noticed some serious performance problems with Java Socket I/O. > You problem is due to a "feature" in the kernel... There's an algorithm in the kernel (Nagle's algorithm) which buffers outgoing data up to 200 miliseconds before sending a packet. The reason for this is to reduce the number of packets sent (little fragments of data). There are two ways to deal with this problem. First, you can use a BufferedOutputStream on your Socket and make sure that you call flush() after a request to the server to make sure that your data is sent right away (not after an idle network period of 200 ms) The second alternative (which I have never tried), is to use the TCP_NODELAY option of sockets which completely disables the fragmentation-reduction algorithm. Have a look at the SocketOptions class in java.net.* This is a new feature implemented in JDK 1.1.x. I don't know why Nagle's algorithm is the default... This may be platform-specific. Anyway, this shows up on Windows NT as well. Regards, Alex Boisvert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message