I am having problems with SocketServer having to wait for a timeout period though I've set allow_reuse_address = True .  I am running this on Linux with JVM 1.6.  It sounds related to Pekkas problem.   I can put together an example for you quite easily using SocketServer.  Would this be helpful to you, or would you rather have one using socket which will take me a little longer.

-----Original Message-----
From: Alan Kennedy <>
To: Pekka Laukkanen <>
Cc: JythonDevelopers <>
Sent: Thu, 26 Jul 2007 3:36 pm
Subject: Re: [Jython-dev] test_socket and test_select_new failures on Mac on trunk

>>>I run socket and select unit test on my Linux machine and got some errors.

>>Try commenting out the "TCPClientTimeoutTest" class in the test_main()
>>function at the bottom of the file.

> Tried that but still got 43 errors most of the time and sometimes 32
> or 35. Errors seem to be same as before and the error message is still
> "error: (98, 'Address already in use')".

Are there any known problems with reuse_address on your platform?

Every single test should be self contained, in that each opens and
closes the server socket, in setUp and tearDown respectively.

If you change the definition of the SocketTCPTest to be like this,
you'll see what I mean

# -=-=-=-=-=-=

class SocketTCPTest(unittest.TestCase):

def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.failUnless(self.serv.getsockopt(None, socket.SO_REUSEADDR))
self.serv.bind((HOST, PORT))

def tearDown(self):
jsocket = self.serv._get_jsocket()
del jsocket
self.serv = None

# -=-=-=-=-=-=

It would be good to see the state of the server socket between tests, by
looking at the output of netstat.

Insert a delay or a pause in the setUp method of the class above, and
examine the state of port 50007 using netstat. If you see sockets in
TIME_WAIT or FIN_WAIT_? states, then there may be problems with the
socket implementation.

Did you say that you're running on a dual-cpu machine? Perhaps the
threads being distributed across two cpus might be causing timing
issues. Although the test_socket module uses threading.Event's to avoid
this. Try inserting a 1-10 second time.sleep at the beginning of the
SocketTCPTest.setUp method, to see if that makes a difference.

Lastly, googling "serversocket bindexception ubuntu" yields other

1. Port number is priviledged, i.e. < 1024. I presume that you have not
changed the test port number from 50007.

2. The 'localhost' interface is not working properly.

Lastly, what JVM are you using?



This email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>
Jython-dev mailing list

Check Out the new free AIM(R) Mail -- Unlimited storage and industry-leading spam and email virus protection.