[xSocket-develop] XSocket not closing underlying OS socket when close() is called
Status: Inactive
Brought to you by:
grro
|
From: Erin D. <eri...@gm...> - 2010-02-25 03:30:27
|
Hi,
I am developing an application using xSocket. During the testing, it
gets shut down and started up again almost instantly. This makes it
crash with a "BindException: Address already in use".
It appears as though xSocket does not tell the operating system that
it has finished with the socket when close() is called. If I wait a
few minutes, the operating system realises the socket isnt being used
anymore and closes it, which means I can start my application again
without it throwing an error.
Is there a solution to this? Here is a test case displaying the behaviour:
import org.junit.Test;
import org.xsocket.connection.IHandler;
import org.xsocket.connection.Server;
/**
* Tests rapid creation and destroying of xSocket sockets
* Will throw an exception on the 2nd or 3rd iteration
*/
public class XSocketTest implements IHandler {
@Test
public void test() throws Exception {
Server s;
for (int x = 0; x < 500; x++) {
s = new Server("localhost", 6789, this);
s.start();
Thread.sleep(100); //give it some time to initialise
s.close();
}
}
}
I am using Linux 2.6 (in case this is NIO-related)
Cheers,
Erin
|