Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

code toknow remotesystem IPAdress is either public orprivate sing vc+

srisaisrisai Member Posts: 5

plz send the code or methods to know the remote System IPAdress is either PublicIPAdress or PrivateIPAdress using vc++ code.

Comments

  • zibadianzibadian Member Posts: 6,349
    :
    : plz send the code or methods to know the remote System IPAdress
    : is either PublicIPAdress or PrivateIPAdress using vc++ code.
    :
    If you have the IP address of the remote system, then you can check the individual byte whether it is private or not. This page lists the private byte values: http://en.wikipedia.org/wiki/Private_network
    The IP address 127.0.0.1 could also be considered to be private.
  • srisaisrisai Member Posts: 5
    : :
    : : plz send the code or methods to know the remote System IPAdress
    : : is either PublicIPAdress or PrivateIPAdress using vc++ code.
    : :
    : If you have the IP address of the remote system, then you can check
    : the individual byte whether it is private or not. This page lists
    : the private byte values: http://en.wikipedia.org/wiki/Private_network
    : The IP address 127.0.0.1 could also be considered to be private.

    hi zibadian ,thanks for reply.. but i have to prove programatically using some methods, if we give input as IPAdress, it has to return the IPAdress as public or Private using VC++ simple methods..plz try using methods
  • zibadianzibadian Member Posts: 6,349
    : : :
    : : : plz send the code or methods to know the remote System IPAdress
    : : : is either PublicIPAdress or PrivateIPAdress using vc++ code.
    : : :
    : : If you have the IP address of the remote system, then you can check
    : : the individual byte whether it is private or not. This page lists
    : : the private byte values: http://en.wikipedia.org/wiki/Private_network
    : : The IP address 127.0.0.1 could also be considered to be private.
    :
    : hi zibadian ,thanks for reply.. but i have to prove programatically
    : using some methods, if we give input as IPAdress, it has to return
    : the IPAdress as public or Private using VC++ simple methods..plz
    : try using methods
    :
    Here is a simple method. I'm not really a C++ programmer, so it might contain several errors. I've never heard of a windows API function to check if a certain IP is part of a privately defined network or not.
    [code]
    class IPValidator {

    bool isIPPrivate(byte[] ip) {
    return (ip[0] == 10) ||
    ((ip[0] == 172) && ((ip[1] > 15) && (ip[1] < 32))) ||
    ((ip[0] == 192) && (ip[1] = 168)) ||
    isIPLocal(ip);
    }

    bool isIPLocal(byte[] ip) {
    return (ip[0] == 127) && (ip[1] == 0) && (ip[2] == 0) && (ip[0] == 1);
    }
    }
    [/code]
  • srisaisrisai Member Posts: 5
    : : : :
    hi Zibadian,we have to find the Certain IPAdress
    is either public or private using VC++MFC Predefined methods.


    : : : : plz send the code or methods to know the remote System IPAdress
    : : : : is either PublicIPAdress or PrivateIPAdress using vc++ code.
    : : : :
    : : : If you have the IP address of the remote system, then you can check
    : : : the individual byte whether it is private or not. This page lists
    : : : the private byte values: http://en.wikipedia.org/wiki/Private_network
    : : : The IP address 127.0.0.1 could also be considered to be private.
    : :
    : : hi zibadian ,thanks for reply.. but i have to prove programatically
    : : using some methods, if we give input as IPAdress, it has to return
    : : the IPAdress as public or Private using VC++ simple methods..plz
    : : try using methods
    : :
    : Here is a simple method. I'm not really a C++ programmer, so it
    : might contain several errors. I've never heard of a windows API
    : function to check if a certain IP is part of a privately defined
    : network or not.
    : [code]:
    : class IPValidator {
    :
    : bool isIPPrivate(byte[] ip) {
    : return (ip[0] == 10) ||
    : ((ip[0] == 172) && ((ip[1] > 15) && (ip[1] < 32))) ||
    : ((ip[0] == 192) && (ip[1] = 168)) ||
    : isIPLocal(ip);
    : }
    :
    : bool isIPLocal(byte[] ip) {
    : return (ip[0] == 127) && (ip[1] == 0) && (ip[2] == 0) && (ip[0] == 1);
    : }
    : }
    : [/code]:

Sign In or Register to comment.