wood burning stoves*
The moose likes Linux / UNIX and the fly likes how to see if a port is in use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to see if a port is in use" Watch "how to see if a port is in use" New topic
Author

how to see if a port is in use

Manju choudhary
Greenhorn

Joined: Feb 04, 2011
Posts: 2
Hi All ,

i want to know how can i know if this port is in use or not (in unix).

eg if i change ssl port to 8444 should it be shown by "netstat -nap " command .
i tried but it does not show any entry for this.

how can i b sure than this port is not in use by any other app.

thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Sounds like a Linux/Unix question, not a JBoss question. Moving.

And when you write "in unix", what "unix" do you mean? Solaris?


JBoss In Action
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Try to occupy the port. If it is in use, you should get an error.

If it is free, you aren't sure whether it will be free in the next second, but of course you may use
with the appropriate hostname/IP instead of localhost.

nmap might need installation.


http://home.arcor.de/hirnstrom/bewerbung
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Actually, there's 2 ways that a port might be in use. One is as a listener port, the other is as a reply port. Listener ports are things like 80, 8080, 25, 443, 5432 and so forth. Reply ports are dynamically assigned on a short-term as needed to faciliate a 2-way conversation. For example, to receive the response on an HTTP request or to maintain the client-inbound link on a client/server session.

For the most part, reply ports can be ignored. They're assigned from an unlikely set of numbers. To check for a listener port, use the "-l" option of netstat.

This should tell you if port 80 is in use, for example:



Feel free to use egrep if you don't want to cascade plain greps. And be sure to include the trailing space in the expression, or you get false hits on things like port 8080!

Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to see if a port is in use