How can i find out the occupied ports in the server machine. so that when we do the instalation, of some program or a server using java, I can change my port number dynamicaly.
Victor Htet
Ranch Hand
Joined: Apr 09, 2000
Posts: 70
posted
0
I don't know what kind of server you are using. If you are using NT server, there is a free utility called Active Ports. you can download it free at www.ntutility.com. You can view which ports are occupied by which processes.
SCJP,SCWCD,SCEA,SCDJWS
Joel Peach
Greenhorn
Joined: Oct 12, 2001
Posts: 19
posted
0
Something else that works is the NT/2000 netstat command. > netstat -a This will dump all allocated/active sockets on all addresses. There is also a good Linux portscan utility and graphical frontend, but for the life of me, I can't remember the name of it. Best of luck! -Joel jpeach@traceris.com
Kyle Willkomm
Ranch Hand
Joined: Sep 10, 2001
Posts: 44
posted
0
Aren't you asking how to scan for the varios port's status in Java? Not with a third party utility? If not I would like to know anyhow if anyone knows of a way. And beyond that perhaps. What process and pid are running on that port? In case you have to use a particular port and can not find which process you need to kill to free up that port.
Glenn Murray
Ranch Hand
Joined: Dec 07, 2001
Posts: 74
posted
0
I thought it was the original author's intent to find out which ports were available from within the application---if not, it is certainly my question. When my users start the app I want the app to find out if, say, port 1099 (to pick a not quite random example) is already in use, and if so, to pick another one. I don't want my users to have to run nmap or netstat to find this out. I've run into conflicts with Netscapes Smart Update on port 1099, in fact. Glenn [This message has been edited by Glenn Murray (edited December 11, 2001).]
Here is a possible solution. You can run a batch program from the Java program that would run netstat and pipe the output to a text file. You could then read this file from the Java program to find out the ports in use. Or, maybe there is a way to bypass writing it to a file, and read it directly??? Does anyone know if this is possible? Hope this helps!
Shubhrajit Chatterjee
Ranch Hand
Joined: Aug 23, 2001
Posts: 356
posted
0
This is a slow, but all java solution
However, I find the idea quite silly. If your server runs on a port which is decided dynamically then how on earth will the clients know where to connect ???