user30724
user30724

Reputation: 235

How to determine what server is listening on Port 80

I need to determine, what web server (IIS, Apache, Jetty) is running on port 80 in Java.

Are there any solutions to get the informations via port 80?

Thanx and reguards

Stefan

Upvotes: 3

Views: 2136

Answers (2)

Michael Borgwardt
Michael Borgwardt

Reputation: 346317

Look at the Server: HTTP header. It will usually contain something like this:

Server: Apache/2.2.10 (SpaceNet) PHP/5.2.6

Of course, the server can send whatever it likes, or not send anything at all.

Upvotes: 3

Rup
Rup

Reputation: 34408

You can ask it - issue a HEAD request, e.g. open a TCP connection on port 80 and just send

HEAD / HTTP/1.0

or

HEAD / HTTP/1.1
Host: the.server.hostname.com

and the reply should contain a Server line

Server: Microsoft-IIS/5.1

amongst other things.

If you want to ask the OS which process, though, I don't know a Java-portable way. Command line you would run netstat -ano or (-anp on linux I think) which will give you the process number listening on port 80, and then you can look that up to find out exactly which server has the port.

Upvotes: 6

Related Questions