Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Haven't tried it myself, but this might tell you how: Day 4.
figured it out later today with some lo level network code, but will definitely look at this. I guess there must be an easier way of finding it then how I did it. I'll also post my code if anyone's interested.
I would be interested...the "day-4-code" is - judged by some other posts - not the "officially supported way"...at least they say so :-)
Just in case it wont survive the next OS or SDK update it would be cool to have another way to get your own ip!
I'll post my code tomorrow when I'm back in the office. Actually my could also be stop working at some time, you never know what apple does with next SDK release.
//this will get you the right IP from your device in format like 198.111.222.444. If you use the for loop above you will se that ip_names array will also contain localhost IP 127.0.0.1 that's why I don't use it. Eventualy this was code from mac that's why it uses arrays for ip_names as macs can have multiple IPs return [NSString stringWithFormat:@\"%s\", ip_names[1]]; }
Looking through the docs it looked like the official way to get the host address would be to use Core Foundation's CFHost, which OTOH is possibly a prettier version of the C code you just posted.
Network code on Mac is always complicated :). But this definitely works and I think should work as it really uses basic C socket functions.
I have not had my C programming Hat on in years. Does this code pull the available connections in the process of determining your IP address?
Im trying to simply see the connections available or otherwise that exist around the iDevice. I want to build a crude location marker system for iDevices that do not have GPS and are not in Location Services registered areas or do not have a wifi connection.
I dont need to access to the networks I just need to know what networks are around the unit. Relative strength would be a plus. But just seeing them would be a start.
Any thoughts on where to look up code or other reference material would be appreciated.
Sorry to bring up this old question, but I've been trying to figure out how to use the "official way" to find out the iPhone's current IP address using CFHost.
However, I haven't been able to successfully do so yet. While I'm sure the above code works, any help with the CFHost version would be much appreciated!
Sorry to bring up this old question, but I've been trying to figure out how to use the "official way" to find out the iPhone's current IP address using CFHost.
However, I haven't been able to successfully do so yet. While I'm sure the above code works, any help with the CFHost version would be much appreciated!
Just curious why you want the IP address - it's going to change when someone moves from network to network, and when someone goes from cell to wifi. I hope you've planned for that situation.
Sorry to bring up this old question, but I've been trying to figure out how to use the "official way" to find out the iPhone's current IP address using CFHost.
However, I haven't been able to successfully do so yet. While I'm sure the above code works, any help with the CFHost version would be much appreciated!
Replies
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks gradha,
Jume
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeJust in case it wont survive the next OS or SDK update it would be cool to have another way to get your own ip!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIt's simply C. So to get started I created IPAddress.h and IPAddress.c
IPAdress.h
IPAddress.c
And then I use it like this in myAppDelegate
MyAppAppDelegate.h
MyAppDelegate.m
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomethanks for sharing this. I understand now why you think this seems complicated... :-)
But I think it will help nevertheless...it's always good to see other solutions to learn how things can be done!
bye, Markus.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeDoes this code pull the available connections in the process of determining your IP address?
Im trying to simply see the connections available or otherwise that exist around the iDevice. I want to build a crude location marker system for iDevices that do not have GPS and are not in Location Services registered areas or do not have a wifi connection.
I dont need to access to the networks I just need to know what networks are around the unit. Relative strength would be a plus. But just seeing them would be a start.
Any thoughts on where to look up code or other reference material would be appreciated.
Thanks
Dietrich
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeHowever, I haven't been able to successfully do so yet. While I'm sure the above code works, any help with the CFHost version would be much appreciated!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThe low-level BSD (er, Darwin, er, iPhone OS...) OS calls are fair play, and I think a lot of iPhone developers don't realize that.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomeit's a little shorter than my method described above ...
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome