How to Retrieve IP address of a mobile phone
Hello,
I have very Genuine Question, as we get connected to the internet through computer at that time we send our IP Address of a machine over internet, if I am accessing internet through Mobile phone so that can we retrieve the IP Address of a Mobile phone? is Mobile phone have an IP address? and which IP address do we get?
Surely it is difficult, please try to solve.
Thank you
Re: How to Retrieve IP address of a mobile phone
This is the recurring question. The final answer is of course, listing them all using the following code:
Code:
// - assumes socket is already Open
// - allocate from heap, because this is large structure
TSoInetInterfaceInfo *inf = new TSoInetInterfaceInfo;
if (inf == NULL)
return KErrNoMemory;
TPckg<TSoInetInterfaceInfo> opt(*inf);
TInt err = socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl);
if (err == KErrNone)
{
while (socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, inf) ==
KErrNone)
{
if (inf().iAddress.IsUnspecified())
{
// Interface inf().iName has no address
}
else
{
// interface inf().iName has address inf().iAddress
}
}
}
delete inf;
Now, the question is which one do you use? When no interfaces are up, you only see the loopback addresses ("::" and 127.0.0.1).
Other addresses are only defined when one or more interface is up.
An interface can have multiple addresses.
If your application is such that it actually connects to something, connecting does not need the knowledge of own address. After connect has been succesfull, you can find the correct address from the connected socket.
If you are doing server application, you don't need to know your address either. Just use unspecified address. Of course, your server will not see anything from outside until some interface is up.
Re: How to Retrieve IP address of a mobile phone
You can send sms from your application by subscribing to one of the sms service provider like www.abtxt.com and implementing the API they provide in our application ..and for IP address you can use this link to retrieve
xmlHttp.open("GET","http://api.hostip.info/?ip="+ip,true,null,null);
xmlHttp.send(null);
Re: How to Retrieve IP address of a mobile phone
It was tricky to get the local IP address of the phone when using TCP, but not due to the complexity of the API method (it was something like RSocket::LocalAddress), but the timing. When RGenericAgent returned saying that "okay, connection is up", I still had to wait for a while until it was really up. Figuring out that "while" was tricky, when - as far as I remember, at least - it turned out that we had to wait for a special state change in the connection.
Re: How to Retrieve IP address of a mobile phone
Couldn't you just access the internet from your mobile device and go to a site like: whatismyip.com
???
That should display it one would think? Not sure don't really use phone for internet. Let me know if this works though I'm interested in this also
Cheers
:cool: