How to get the public IP address of the device

How to get the public IP address of the device

By : user2953945
Date : November 21 2020, 07:31 AM
I wish this help you I have used ALSystemUtilities in the past. You basically have to make a call externally to find this out.
code :
+ (NSString *)externalIPAddress {
    // Check if we have an internet connection then try to get the External IP Address
    if (![self connectedViaWiFi] && ![self connectedVia3G]) {
        // Not connected to anything, return nil
        return nil;

    // Get the external IP Address based on dynsns.org
    NSError *error = nil;
    NSString *theIpHtml = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.dyndns.org/cgi-bin/check_ip.cgi"]
    if (!error) {
        NSUInteger  an_Integer;
        NSArray *ipItemsArray;
        NSString *externalIP;
        NSScanner *theScanner;
        NSString *text = nil;

        theScanner = [NSScanner scannerWithString:theIpHtml];

        while ([theScanner isAtEnd] == NO) {

            // find start of tag
            [theScanner scanUpToString:@"<" intoString:NULL] ;

            // find end of tag
            [theScanner scanUpToString:@">" intoString:&text] ;

            // replace the found tag with a space
            //(you can filter multi-spaces out later if you wish)
            theIpHtml = [theIpHtml stringByReplacingOccurrencesOfString:
                         [ NSString stringWithFormat:@"%@>", text]
                                                             withString:@" "] ;
            ipItemsArray = [theIpHtml  componentsSeparatedByString:@" "];
            an_Integer = [ipItemsArray indexOfObject:@"Address:"];
            externalIP =[ipItemsArray objectAtIndex:++an_Integer];
        // Check that you get something back
        if (externalIP == nil || externalIP.length <= 0) {
            // Error, no address found
            return nil;
        // Return External IP
        return externalIP;
    } else {
        // Error, no address found
        return nil;

Share : facebook icon twitter icon
Get Public IP Address of WinRT device in application

Get Public IP Address of WinRT device in application

By : Lyle Hodgson
Date : March 29 2020, 07:55 AM
should help you out A simple way to find your external IP address is to use a open service on the internet.
For example this is taken from here: Getting the external IP address but adapted to work in WinRT
code :
Task<string> result = GetExternalIP();    
string externalIP = (new Regex(@"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"))

public async Task<string> GetExternalIP()
   HttpClient http = new System.Net.Http.HttpClient();
   HttpResponseMessage response = await http.GetAsync("http://www.realip.info/api/p/realip.php");
   return await response.Content.ReadAsStringAsync();
difference between the physical address,device address and virtiual address

difference between the physical address,device address and virtiual address

By : Athar
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further
The documentation says:
Can Amazon EC2 instance have a static public DNS even if public IP address may change?

Can Amazon EC2 instance have a static public DNS even if public IP address may change?

By : Julka
Date : March 29 2020, 07:55 AM
Hope this helps I can never understand when the people ask a question, and the premise of the question is 'i know what the solution to this problem is but I don't want to use it' - the solution is to assign an elastic IP - that is what the elastic IP will do for you - i.e. give you an IP that you can assign and use no matter the underlying instance...That said, generally speaking I have often heard AWS speakers use the analogy that you need to treat your servers like a chicken farmer treats their chickens, not like family treats it's pet.
Pets have names, when pets get sick you bring them to the vet and nurse them back to health. Chicken farmers (large ones anyway), don't name their chickens, and they don't bring them to the vet when they get sick - they let them die, and put in a new on in their place (I know, cruel analogy, but the point is a correct).
Generating bitcoin key pair in python 3.6 from public key to public address

Generating bitcoin key pair in python 3.6 from public key to public address

By : Eddy Kim
Date : March 29 2020, 07:55 AM
I wish did fix the issue. This code runs both in Python 2 and Python 3. It prints not only the bitcoin address, but also some intermediate values. The public key is the 130 hex char string in pubkey variable.
Please note that there are two possible and valid bitcoin addresses for each public key: the uncompressed and the compressed form. Change compress_key boolean variable to extract each one.
code :
#!/usr/bin/env python
# https://en.bitcoin.it/wiki/Protocol_documentation#Addresses

import hashlib
import base58

# ECDSA bitcoin Public Key
pubkey = '0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6'
# See 'compressed form' at https://en.bitcoin.it/wiki/Protocol_documentation#Signatures
compress_pubkey = False

def hash160(hex_str):
    sha = hashlib.sha256()
    rip = hashlib.new('ripemd160')
    rip.update( sha.digest() )
    print ( "key_hash = \t" + rip.hexdigest() )
    return rip.hexdigest()  # .hexdigest() is hex ASCII

if (compress_pubkey):
    if (ord(bytearray.fromhex(pubkey[-2:])) % 2 == 0):
        pubkey_compressed = '02'
        pubkey_compressed = '03'
    pubkey_compressed += pubkey[2:66]
    hex_str = bytearray.fromhex(pubkey_compressed)
    hex_str = bytearray.fromhex(pubkey)

# Obtain key:

key_hash = '00' + hash160(hex_str)

# Obtain signature:

sha = hashlib.sha256()
sha.update( bytearray.fromhex(key_hash) )
checksum = sha.digest()
sha = hashlib.sha256()
checksum = sha.hexdigest()[0:8]

print ( "checksum = \t" + sha.hexdigest() )
print ( "key_hash + checksum = \t" + key_hash + ' ' + checksum )
print ( "bitcoin address = \t" + base58.b58encode( bytes(bytearray.fromhex(key_hash + checksum)) ) )
How to programmatically find the public IP address of a Device?

How to programmatically find the public IP address of a Device?

By : safia tabassum
Date : March 29 2020, 07:55 AM
This might help you We are able to get Local Ip Address with WifiManager or InetAddress. But we need the Current Public IP address programmatically in android. , add the permisition in manifeast file
code :
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
public String GetDeviceipMobileData(){
    try {
        for (java.util.Enumeration<java.net.NetworkInterface> en = java.net.NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
            java.net.NetworkInterface networkinterface = en.nextElement();
            for (java.util.Enumeration<java.net.InetAddress> enumIpAddr = networkinterface.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                java.net.InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    return inetAddress.getHostAddress().toString();
    } catch (Exception ex) {
        Log.e("Current IP", ex.toString());
    return null;

public String GetDeviceipWiFiData(){
    android.net.wifi.WifiManager wm = (android.net.wifi.WifiManager) getSystemService(WIFI_SERVICE);
    String ip = android.text.format.Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    return ip;             
Related Posts Related Posts :
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • webview not showing on full Screen of iphone 6
  • Location Notification's based on Latest iOS Feature
  • Adjusting Height of UITableViewCell
  • How to show five digit unicode in iphone
  • unwind doesn't work
  • Confusion about coordinates, frames & child nodes in SpriteKit on iOS?
  • If Statements not being recognized by Xcode
  • readonly property in RubyMotion
  • 'No available types for source 1' when the app runs on my device(IPhone 6) swift
  • IOS:Remove view when clicked in background
  • Removing "\" from URL in iOS Swift
  • iOS - Send an email automatically (NOT from user's account)
  • The usage of NSNotificationCenter in the relationship of parent and children
  • When do Apple auto-renewable subscriptions renew?
  • Unknown large spacing between x-axis label and base of plot in core-plot
  • How do I change the displayed time format after NSTimer is initiated?
  • Swift JSON breaks when [ ] are used
  • Secure Memory For Swift Objects
  • didSelectItemAtIndexPath doesn't work normally
  • Swift Documentation Comments
  • Is there a simple way to assign a value only once(first time) inside a loop/repeatedly running method?
  • Play sound in while app in background
  • If I have an embedded unrestricted webview, does that mean I have third-party content?
  • UITapGestureRecognizer on UIScrollView
  • App does not respond to hardware volume changes on iPad
  • troubleshoot asp.net web app on iOS
  • What size should my tab bar item icons be?
  • Parse.com Facebook authorize never calls completion handler
  • Implementing iAds on a SceneKit view
  • UIAccessibility and Apple Pay voice-over interaction issue
  • Getting objectForKeyedSubscript unrecognized selector when parsing data in table view
  • Execute action when back bar button of UINavigationController is pressed
  • iOS Table View - Set tag on cell or label?
  • Preferred approach for changing UITableViewCell content based on cell width
  • NSDateformatter dateFromString AnyObject
  • Type specifier for NSMutableArray?
  • iOS7 slideout drawer draggable bug
  • Fetch Core Data entity with a filtered set of child elements based on a property
  • UILabel AutoResize Swift
  • Swift - Selecting cells when having multiple custom cell-classes
  • Table View Cell Prototype from Storyboard not initializing subviews
  • Best way to implement view like map
  • Adding a tap gesture to a UIImageView to change a UILabel?
  • Minimum OS X and xcode requirements for ios 8.1 development
  • Changing the text of the Cancel button in the default TouchID dialog
  • iOS timing between taps
  • Swift: How do I link an action to a view inside of a tableViewCell?
  • Value for frame.size.height is always the same regardless of height of view
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org