I built a client server app开发者_Python百科lication using an IDL file for client server communication across the network. Both the client and server programs are in java. When the user enters exit, both the server and the client exit. However I'm unable to kill the nameserver process. I started the nameserver using the command
tnameserv -ORBInitialPort 1050
How can I kill the nameserver in the client or server programs( which are in java)?
When you run the tnameserv you'll have to kill it via the kill command (linux,unix) or Ctrl+C (windows)
If on linux/unix, this should do the trick:
killall tnameserv
see http://java.sun.com/j2se/1.4.2/docs/guide/idl/tnameserv.html#stoppingnameserver
Edit:
If you want to issue the killall command from withing java use:
runtime.exec("killall tnameserv");
see http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html
Thoughts:
It seems odd to have started the tnameserv from outside of our program, and then try to kill it from within. (permission issues, other users using the nameserv, etc, etc.) Depending on your needs, why not start the tnameserv from within you app?
精彩评论