tags:

views:

130

answers:

6

hi how can i know on which port my application is running

thanks in advance

+4  A: 

What port did you tell it to run on?

(You're going to have to give us more details about exactly what you/your program are/is doing for us to be able to give you a more helpful answer than the above.)

Amber
+1 Great answer.
adatapost
+6  A: 

That's not a lot of information to go on, but if your app is a general purpose TCP server and you're really not sure whether it's running or not, or on what port, try:

netstat -an -p tcp

(This is a UNIX/Linux/OS X command... not sure what the Windows equivalent is but it will be similar)

This will show you all listening sockets on your machine and the IP address/port on which they are listening. One of them may be your app.

Gene Goykhman
netstat -na for windows (netstat -nao on XP/Vista/7 will also show the pid)
Fedearne
on Windows, a free tool named FPort shows the process name with the port
Piskvor
A: 

if you're using tcp\ip or udp fport should fit your needs link text

sid
+1  A: 

There is a nice util at SysInternals called TCPView.exe

http://live.sysinternals.com/Tcpview.exe

That shows all connections and process IDs

Gordon Carpenter-Thompson
A: 

Inside a Servlet you can ask the HttpRequest object how it was invoked including the port and hostname. There is no standard API for a servlet interrogating the container.

Thorbjørn Ravn Andersen
+1  A: 

If your app is a server, and you need to test if it's listening, you can use

netstat -ltpn

The meaning of the switches:

  • -l for "listening", that is, server sockets only
  • -t for "tcp only"; note that you may need udp, then use -u
  • -p for "program": show which process opened which socket
  • -n for "numeric": IPs are OK, don't spend time on looking up hostnames

Run it as root (e.g. with sudo) to get process info on sockets opened by the root's processes.

This is for UNIX/Linux. Please specify the system you're using to get more precise answers.

AttishOculus