"Nelson B. Bolyard" wrote:
> 
> Jung-Ho Ahn wrote:
> >
> > Hello,
> >
> > While I am trying to use NSS (actually JSS) in our HTTP server,
> > I found that I could not a server socket which is
> > waiting for a new connection, since a socket
> > is locked during the 'accept' call.
> > Is there any way to close that socket in another thread?
> 
> Jung-Ho and Jamie:
> 
> Is that a valid thing to do in Java? (to close a socket that's in use
> by another thread) ??

Closing an object that is still in use is illegal.
It may work with some implementations but that doesn't
mean it is a valid thing to do.

Jung-Ho, there are two possible solutions to your problem.

1. Interrupt all the pending 'accept' calls.  You can use
   Java's 'interrupt' method to do so.  I am not sure if
   the 'accept' call would respond to an interrupt though.

2. Artificially connect to your own server socket and send
   it a special command.  On receiving the special command,
   the server socket would close itself.  This solution is
   not elegant but is commonly used because the 'interrupt'
   method doesn't always work.

Wan-Teh

Reply via email to