PDA

View Full Version : How can I get address of wireless router



dpatel
13th March 2011, 18:03
Hi,

I want to write an application which will listen for http requests.
I have limited knowledge about networking so let me know if I am thinking it correctly.

I am thinking that I will create QTcpServer listening at a particular port and when I get the request I can process it. But my PC is connected to internet via a wifi router. How can I get IP address of the wifi router and how can I setup the router so that it will forward request to my application running on my PC.

Let me know if there is another way to do it.

Thanks

wysota
14th March 2011, 10:24
What do you need the router address for?

dpatel
14th March 2011, 11:23
Hi wysota,

This is what I want to achieve.

I want my application (lets call it Listener) to listen to http request from a webapp. Listener is running on a pc which is connected to internet via wifi router. The Ip address of pc on which Listener is running is 192.168.*.* (LAN address). Now if the webapp wants to send the request to Listener what is the best way to do it.

I am thinking that I can ask the webapp to send the request to wifi router which will then forward(I am not sure how the router will forward request to Listener) it to Listener at a particular port where it would be expecting a request. That is why I need the ip address of router. Is that possible? Is there any better way to achieve that?

Thanks

wysota
14th March 2011, 12:23
I am thinking that I can ask the webapp to send the request to wifi router which will then forward(I am not sure how the router will forward request to Listener) it to Listener at a particular port where it would be expecting a request. That is why I need the ip address of router. Is that possible? Is there any better way to achieve that?
Why do you need the ip address of the router? The router is connected to the internet and its external address is known. The external app connects using the router's external IP address (which again is known) that then has to be setup to forward the connection to your local machine (read about "port forwarding" to learn how to do that). Your local machine doesn't need to know the address of the router. The router has to know the address of your local machine.

dpatel
15th March 2011, 02:51
Thanks wysota. Now I understand what you mean. I was not thinking it correctly. Thanks again.

squidge
15th March 2011, 07:54
If you want your application to automatically configure the Wifi router to port forward certain ports to your PC you can do it over UPnP (If enabled on your router, which it typically is by default).

For a single application, this is not so useful, but if you are going to be installing your application on many PCs, it is a time saving feature.

dpatel
30th March 2011, 06:04
Thanks squidge. Is there any library that you know of which I can use with Qt to configure the router ?

squidge
30th March 2011, 07:36
I've seen such libraries before (such as https://code.google.com/p/qupnp/) but have not used them so I can not say how well they work.