473,320 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

IP of a router

hsn
237 100+
hello everyone
i working on a system and i need to get the IP address o a router by using java.
the problem is whenever i create a program it gives me the IP address of my PC . by using a getlocalhost function.

thanks for reading my question

regards hsn
Apr 23 '08 #1
6 2241
Nepomuk
3,112 Expert 2GB
hello everyone
i working on a system and i need to get the IP address o a router by using java.
the problem is whenever i create a program it gives me the IP address of my PC . by using a getlocalhost function.

thanks for reading my question

regards hsn
Do you mean the IP with which your router has connected to the internet? If so, the only option I can think of right now is with a client-server-solution, where the server tells you, what IP you're connecting from... Or of course, your router can tell you itself in some way. What kind of router are you using? Can you run programs on it?

Greetings,
Nepomuk
Apr 23 '08 #2
pronerd
392 Expert 256MB
If this is a web application, and if it is being accessed though a public domain, you could have it send a request to it self. Then you can get the external IP address from the HTTP headers. This will only work if the request you send goes outside your network to be resolved.

whenever i create a program it gives me the IP address of my PC . by using a getlocalhost function.
That is what it should do. The getlocalhost() method as the name suggests gets the local host info.
Apr 23 '08 #3
hsn
237 100+
take it like this there is only one PC and it is connected to a router. there is no internet connection.

thanks
Apr 26 '08 #4
hsn
237 100+
the IP address which i require is the local gateway address
Apr 26 '08 #5
pronerd
392 Expert 256MB
there is no internet connection.
There does not need to be. You can run a server without an internet connection.

The bottom line here is that the information you are looking for does not exist on the PC you are running your Java app on. So there is no way for the JRE to know what you want.

I am assuming that router must be connected to something else other than a single PC. If not then it does not matter what IP is assigned since there would be nothing else to connect to.
Apr 29 '08 #6
pronerd
392 Expert 256MB
the IP address which i require is the local gateway address
Of the router or the PC? What are you trying to use the gateway IP for? The whole point of Java is to not have to be tied that closely to the hardware you are running on.
Apr 29 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John J. Hughes II | last post by:
My code starts a TCP/IP socket listener and waits for incoming connections. This works fine on my system and my test system but I have a customer who say it does not work on their system. As far...
2
by: cyshao | last post by:
How to reset Router by programing? For some resean, we need usually reset our Router. Now, we have to Reset Router manually(shot down and reopen). Are there any method to control and reset...
3
by: steve | last post by:
anyone know how to get a network router's external ip address? any examples w/b great! tia, steve
0
by: John | last post by:
Today something weird happened: I bought myself a new wireless router for home, got it set up, and everything was great. Browsing, email, even Shareaza p2p. Until I tried to use the ASP.NET 2...
0
by: mario.lat_ | last post by:
Hallo to all, I have write a little script for connecting to cisco router BUT I have a problem: I have to send to router all the commands and then I have to read the output. If I send a command1...
4
by: seets375 | last post by:
Hi, I have two ethernet interfaces on my system, with IPs assigned to the interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 - 20.20.20.20 ). I'm connecting these interfaces to...
3
by: =?Utf-8?B?Vk1BTQ==?= | last post by:
Hi, I have a home network with a DSL router. I want to check the router state (connected, disconnected...) from an XP computer on the network by showing an icon (green / red) in the system tray....
5
by: =?Utf-8?B?SmltbWVy?= | last post by:
Hello, I've been trying to create a WCF SOAP Router Service that can forward not just the message body but also any security headers set by the originator of the message. The destination service...
1
by: izecul | last post by:
Hi, I'm a newbie here, and what I know about networking you can probably copy on a matchbook :) That said, here's my problem: I've got two wireless routers - D-Link DI-524 and Airlink AR325W....
3
by: apg018 | last post by:
Hi - I just bought an Asus laptop with wireless capabilities. I have a desktop that I've used for years that is hooked up to Cox cable for high speed internet through a Motorola SG5120 cable modem....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.