I have a program where i need to need to use the public IP in it. Since i m on a BSNL connection i cant hardcore the public Ip in it since the IP i use is dynamic.
The code is written in java and i know of one such command which is
String xyz = InetAddress.getLocalHost().getHostAddress();
The above statement returns the local IP of the system, but what i need is the public IP . Have looked for it in the API but couldnt make anything out of it
So , is there any particular method that returns the public ip
Also, does anybody here have an idea about rtpmanager,avreceiver,avtransmitter programs
Woohoo..karan , slow down mate. I m not a professional yet
Even i thought of getting it from a website , but then , didnt know how to get data from there. All i know is output streams and input streams , which doesnt work in a situation like this.
So, how do you capture your IP from a webpage like that
And more over, isnt there a method in Inet or somewhere for directly recalling it ?
isnt there a method in Inet or somewhere for directly recalling it ?
Here’s a layman explanation of why it wouldn’t work that way…
windows may not necessarily know the public IP address…Since in most cases, the modem /router would be NATing the public IP to a private IP on the internal network
@leomax, thats where i m stuck man. that buffered reading would give everything thats on one given page. So, to get the IP address from all the data that is returned in input stream i will need to do either of these two things
1)find a url thats returns only the IP address
2)Else find a logic that i can use for tokenising the data and getting the IP address off it from a webpage like whatismyip.com
@super, i agree that the router does the assigning of IP, but once thats done the OS also knows about the current public IP of the system. Thats why the IP address is displayed under ipconfig , and even in the status window of network connections.So i was just thinking if there could be possibly a method of calling it directly.
Karan , could you please throw some light on screen scrapping and regex, if it doenst take much of your time
Thats why the IP address is displayed under ipconfig , and even in the status window of network connections.So i was just thinking if there could be possibly a method of calling it directly.