Hi,

It seems the same problem of HARMONY-6090 and discussed here [1].

In Harmony, the SO_REUSEADDR's default value of ServerSocket is false on Linux, while RI is true, that cause the bind failed. I have attached a patch to fix it in Java code, you can try it :)
I think it's better if it could be done in native code.

[1] http://harmony.markmail.org/search/?q=SO_REUSEADDR#query:SO_REUSEADDR+page:1+mid:ylkmq4aaclmcr55b+state:results

[email protected] wrote:
Author: hindessm
Date: Wed Feb 25 15:13:52 2009
New Revision: 747813

URL: http://svn.apache.org/viewvc?rev=747813&view=rev
Log:
This test often fails for me because if the client connect completes
before the server socket closes then the client socket is left in
CLOSE_WAIT state. The CLOSE_WAIT socket is then still using the port
so the SECOND_TIME bind fails.  Oddly it passes 100% of the time on
the RI because the close always seems to happen before the connect
completes and so the connect always fails with 0 return code.

Modified:
    
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Modified: 
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=747813&r1=747812&r2=747813&view=diff
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
 Wed Feb 25 15:13:52 2009
@@ -93,8 +93,8 @@
                 }
socket.setSoTimeout(5000);
-                socket.accept();
-
+                Socket client = socket.accept();
+                client.close();
                 socket.close();
             } catch (IOException e) {
                 e.printStackTrace();





--
Best Regards,
Regis.

Reply via email to