i need to listen requests coming on port 80 in order to authenticate these request from free radius server but i want to know is it necessary to create a new serversocket object on port 80 as whenever i do so it says "java.net.BindException: Address already in use" , how can i listen for the traffic with out creating a serversocket object.
One and only one can listen to a port at each time. If your normal web server is listening to calls on port 80, then you can't do it also.
If you want to listen to the port, then you need to start listening to it and if the web server then should get the request if any logic is validated, then you need to forward it to the web server that is then listening to another port.
An example is when you put Apache HTTPD in the front, listening to port 80 and delivering static data, and forward JSP calls to a Tomcat that listens to port 8080.
The problem is that another program is already listening to port 80. If it's a Windows machine, you maybe have Microsoft IIS or other webserver software running on the machine. You need to stop that program before your own program can listen to port 80.
Note that on most Unix-like operating systems, including Linux and Mac OS X, you can only listen to ports under 1024 when you have root rights. A normal program which doesn't run as root will not be allowed to listen on ports below 1024.
actually i don't want to switch off any thing running on port 80 but want to listen incoming requests on the port 80 , so to do it with java i was needed to create a new ServerSocket object which was not allowed because a process is already running on the port. i wanted to do it by forwarding port 80's traffic to another port where i can make a new ServerSocket object on that new free port.
Joined: Mar 22, 2005
forwarding traffic to some other port means the aolserver thingie won't get any requests - that's not what you want, either, right? So you need to figure out how to run your stuff as part of the aolserver.
i just want to keep my application separated from any thing running on the port 80 because in case of many servers i won't be able to know what is running on port 80.
Then you need to change the program that is listening to port 80 to forward to your port and then receive the traffic on port xxxx and forward it to the original port 80 that will forward it to port xxxx... (I can do this all night... ;) ).
What you are trying to do is a network sniffer. There are two ways to do that.
1. Create a proxy and have your program put in front of the actual application that was listening to port 80. As suggested.
2. Hack yourself into the IP-stack and pull the data from there.
And also, tell whomever you want to sniff the traffic from that you are trying to find out what that person is doing on port 80...
Edit: What do you mean with "I don't know what is listening on port 80"? If you do not know, then you are by 99.9% probability not allowed to do it in the first place... ;)
Not exactly that, i wanted to forward incoming authentication request on port 80 to radius client which will get them authenticated from radius server, if authenticated then proceed to original port.
and some times it is possible that its apache or aolserver there on port 80 so i didn't wanted to bother about that .
any body will not be needed to do forwarding all night it will be done with a simple thread using jsch library.