Re: ServerSocket.getLocalPort possible bug...

2005-10-09 Thread Mark Wielaard
Hi Martin,

On Wed, 2005-09-21 at 13:20 -0400, Martin Cordova wrote:
 Winstone's author explained to me the following:
 
 I know what this is - it's because socket.getLocalPort() returns -1. I
 hit this when I was trying to run winstone on GCJ too, about 12 months
 ago, but didn't report it. The listener code does:
 
req.setServerPort(socket.getLocalPort());
 
 
 I observed this bug when navigating to http://mylinuxBox from a remote
 windows box using IE6, IE complained about no response. I found in the
 servlet logs the following:
 
 Headers prepared for writing: [Location: http://192.168.1.1:-1/index.htm
 
 Which means that a redirect from root context to the welcome page was
 being sent to the browser, but the -1 port troubled IE6.

Fixed now. Tested against the winstone setup you sent me and the test
servlet works nicely and reports the correct port number now.
See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24006
The fix will be in the 0.19 release (hopefully first week of November).

Cheers,

Mark


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


ServerSocket.getLocalPort possible bug...

2005-09-21 Thread Martin Cordova
Hello:

While testing Winstone servlet engine (winstone.sourceforge.net) on
JamVM 1.3.3 with Classpath 0.18, I found a possible bug:

getLocalPort returns -1 when it should return 80. In fact the same
program on the same box, when running with Sun or IBM JVM works fine.
So I suspect it may be a problem in ServerSocket implementation.

Winstone's author explained to me the following:

I know what this is - it's because socket.getLocalPort() returns -1. I
hit this when I was trying to run winstone on GCJ too, about 12 months
ago, but didn't report it. The listener code does:

   req.setServerPort(socket.getLocalPort());


I observed this bug when navigating to http://mylinuxBox from a remote
windows box using IE6, IE complained about no response. I found in the
servlet logs the following:

Headers prepared for writing: [Location: http://192.168.1.1:-1/index.htm

Which means that a redirect from root context to the welcome page was
being sent to the browser, but the -1 port troubled IE6.

Hope it helps.

Regards,
Martin
--
Dinamica - Open source J2EE framework
Free, easy and powerful
http://www.martincordova.com


___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: ServerSocket.getLocalPort possible bug...

2005-09-21 Thread Mark Wielaard
Hi Martin,

On Wed, 2005-09-21 at 13:20 -0400, Martin Cordova wrote:
 Winstone's author explained to me the following:
 
 I know what this is - it's because socket.getLocalPort() returns -1. I
 hit this when I was trying to run winstone on GCJ too, about 12 months
 ago, but didn't report it. The listener code does:
 
req.setServerPort(socket.getLocalPort());
 

Thanks for reporting the bug. For bonus points please file the bug
through http://www.gnu.org/software/classpath/bugs.html
That way it is easier to track (sadly sometimes bug just sent to the
mailinglist get lost in other conversations).

I don't have a patch yet, but a created the attached Mauve
(http://www.sourceware/org/mauve/) unit test that shows the issue:

FAIL: gnu/testlet/java/net/ServerSocket/AcceptGetLocalPort (number 2)
got -1 but expected 5678

Cheers,

Mark
/* AcceptGetLocalPort.java - Test for getLocalPort on accepted Socket.
   Copyright (C) 2005, Mark J. Wielaard  [EMAIL PROTECTED]

This file is part of Mauve.

Mauve is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

Mauve is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with Mauve; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
   
// Tags: JDK1.0

package gnu.testlet.java.net.ServerSocket;

import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;

import java.net.*;
import java.io.*;

public class AcceptGetLocalPort implements Testlet, Runnable
{
  private static int port = 5678;

  public void test (TestHarness harness)
  {
new Thread(this).start();
try
  {
	ServerSocket ss = new ServerSocket(port);
	harness.check(ss.getLocalPort(), port);
	Socket s = ss.accept();
	harness.check(s.getLocalPort(), port);
	s.close();
	ss.close();
  }
catch (IOException ioe)
  {
	harness.debug(ioe);
	harness.check(false, ioe.toString());
  }
  }

  public void run()
  {
int i = 0;
while (i  10)
  {
	try
	  {
	Socket s = new Socket(localhost, port);
	break;
	  }
	catch (IOException ioe)
	  {
	// ignore
	  }
	try
	  {
	Thread.sleep(1000);
	  }
	catch (InterruptedException ie)
	  {
	// ignore
	  }
  }
  }
}


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath