Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- warning: no '+currentHost' method found
- warning: (Messages without a matching method signature)
- -(NSString*)getAddress {
- char iphone_ip[255];
- strcpy(iphone_ip,"127.0.0.1"); // if everything fails
- NSHost* myhost = [NSHost currentHost];
- if (myhost)
- {
- NSString *ad = [myhost address];
- if (ad)
- strcpy(iphone_ip,[ad cStringUsingEncoding: NSISOLatin1StringEncoding]);
- }
- return [NSString stringWithFormat:@"%s",iphone_ip];
- #include <arpa/inet.h>
- #include <netdb.h>
- #include <net/if.h>
- #include <ifaddrs.h>
- // retun the host name
- + (NSString *)hostname
- {
- char baseHostName[256];
- int success = gethostname(baseHostName, 255);
- if (success != 0) return nil;
- baseHostName[255] = '