Thank you for your help.
I believe I fixed it, it now only waits about 6 to 8 seconds before
command prompt appears. I do not think that is a problem, to me anyway :).
I changed it to:
public void disconnect() {
if (session != null) {
System.out.println("Disconnecting client.");
CloseFuture cf = session.close(true);
cf.addListener(new CloseSessionListener());
cf.awaitUninterruptibly(CONNECT_TIMEOUT);
session = null;
}
}
class CloseSessionListener implements IoFutureListener<CloseFuture> {
public void operationComplete(CloseFuture future) {
connector.dispose();
}
}
The disconnect client appears then 6 to 8 seconds later the command
prompt appears.
Kelly
Emmanuel Lecharny wrote:
Kelly Wiles wrote:
Java version 1.6.0_13-b03
Windows XP Pro 2002 SP 3
Would be easiest if I could send a zip file.
The zip file will contain source code, thread dump, client jar file
and server jar file and misc jars to run code.
Unzip into a new folder.
To run the server prototiger_srv-1.0.0.jar on one computer
java -Djava.library.path=. -jar prototiger_srv-1.0.0.jar 2000
And on another computer execute
java -Djava.library.path=. -jar prototiger_clt-1.0.0.jar <ip address
of server> 2000
The zip file can be downloaded at
http://www.tabbyinstall.com/example-20090606.zip
Kelly
Ok, got it. What you are trying to do is to close the session when you
receive a specific message (PtServer_3). That's fine except that if
you close the session which is processing the disconnecting packet,
then the client will close the session, leaving the NioConnector
alive, and doing nothing. This is why it seems to wait forever.
What really happens is that the session is closed when the timeout has
expired (3 seconds).
The only way to close correctly the client is to register a listener
in the closeFuture :
David Rosenstrauch has sent a mail where he explains the way to do that :
public class ShutdownCommand extends TextProtocolCommand {
...
public ProtocolResponse execute() throws Exception {
...
CloseFuture closeFuture =
getSession().close(closeImmediately);
closeFuture.addListener(new CloseSessionListener());
return null;
}
...
class CloseSessionListener implements
IoFutureListener<CloseFuture>
{
public void operationComplete(CloseFuture future) {
getServerControl().shutDown();
}
}
}
public class CacheServer implements CacheServerControl {
...
public void shutdown() {
logger.debug("{} protocol processor shutting down server
socket", protocolType);
protocolAcceptor.unbind();
protocolAcceptor.dispose();
}
private String protocolType;
private SocketAcceptor protocolAcceptor;
private Logger logger;
}
Hope it helps.
--
Schedule A Meeting
Meeting Management Software
http://sam.kdkhome.com/
Tabby Install and Tabby Editor for Eclipse
Create application install programs easily.
http://www.tabbyinstall.com/
Jar Compiler an Eclipse Plugin
Compile Java Jar files into a native executable.
http://www.tabbyinstall.com/jarc/JarCompiler.html
ISO Builder an Eclipse Plugin
Create CDROM ISO images.
http://www.tabbyinstall.com/isobuilder/ISOBuilder.html
ProtoTiger for the Apache Mina project.
Generates client/server source code from GUI design.
http://www.tabbyinstall.com/prototiger/ProtoTiger.html