Closing a socket is not freeing the port!!

hi,

Using socket.close() and setting the socket = null, is not enabling a port to be reused - seemingly until my application is closed. Java thinks the port is closed, so I think this is an OS problem.

Im using jdk1.3.1, WinNT 4.0.

Is this a known problem, any solutions?

Have been changing the socket options to no avail...

socket.setNoTcpDelay()

socket.setSo_Linger()

socket.setSo_KeepAlive()

socket.setSo_Timeout()

Any thoughts most appreciated...

[534 byte] By [cs0amc] at [2007-9-26 2:13:36]
# 1
Could you just close the socket and not set it to null? There was a similar thread http://forums.java.sun.com/thread.jsp?forum=11&thread=16664
swatdba at 2007-6-29 9:08:25 > top of Java-index,Archived Forums,Socket Programming...
# 2
Thanks bud, have checked the other thread.I have tried closing the socket and setting the socket to null, but this still does not allow me to reopen a socket on the same port....
cs0amc at 2007-6-29 9:08:25 > top of Java-index,Archived Forums,Socket Programming...
# 3

Related problem -

1) host thread creates a SocketServer object on port 3700, then does a Socket socket = serverSocket.accept(), which blocks, waiting.

2) applet creates a Socket on host's port 3700, which causes the host's accept() to wake up and return (creating a Socket object on the host).

3) applet create ObjectOutputStream from it's Socket

4) host creates ObjectInputStream from it's socket and does a Vector vect = (Vector)objectInputStream.readObject(), which blocks...

5) applet does a ObjectOutputStream.writeObject(myVector) and voila! host receives the vector

Problem: if I refresh the applet , somehow the host thread has to be informed, to know to start over. Or the ObjectOutputStream has to be preserved during the refresh. Any ideas?

mesas at 2007-6-29 9:08:25 > top of Java-index,Archived Forums,Socket Programming...