Is your application running on a webserver? (Tomcat/Apache)
Main Topics
Browse All TopicsDoes any one know the way to find how many applications are calling my application ?
I mean I want to find the IP addresses + Port no of the machines from which the request for my application is coming.
This has to be in java.
I have written the following code in java…..
Enumeration e = NetworkInterface.getNetwor
while(e.hasMoreElements())
{
NetworkInterface netface = (NetworkInterface) e.nextElement();
Enumeration e2 = netface.getInetAddresses()
while (e2.hasMoreElements())
{
InetAddress ip = (InetAddress) e2.nextElement();
if(!ip.isLoopbackAddress()
{
byte[] ipAddr = ip.getAddress();
System.out.println("Host Name : " + ip.getHostName());
localip[0]=(ipAddr[0]&0xFF
localip[1]=(ipAddr[1]&0xFF
localip[2]=(ipAddr[2]&0xFF
localip[3]=(ipAddr[3]&0xFF
System.out.println("IP Address is : " + localip[0] + "." + localip[1] + "." + localip[2] + "." + localip[3]);
}
}
}
This gives me the IP addresses n the hostnames of all the remote machines.
But how to get the remote port no ???
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In the SecurityManager you can put this:
public synchronized void checkConnect(String host,int port){
Calendar cal=Calendar.getInstance()
System.out.println("CheckC
super.checkConnect(host,po
}
public synchronized void checkConnect(String host,int port, Object context){
Calendar cal=Calendar.getInstance()
System.out.println("CheckC
super.checkConnect(host,po
}
Business Accounts
Answer for Membership
by: Giant2Posted on 2006-01-30 at 03:04:17ID: 15822522
>Does any one know the way to find how many applications are calling my application ?
In your servlet use a static counter.
Each time your servlet is called it increment this static variable.
>But how to get the remote port no ???
Your servlet is on a webserver. The port the servlet answer is only 80 (or 8080 ot other defined in the configuration parameters).
The remote port nr. is known only by the remote machine.