Howdy, Stranger!

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

Categories

Help me I want to convert ip address to decimal number

plalardplalard Member Posts: 7
I want to convert ip address to decimal number and reconvert it.

Examples : If i get 203.107.160.32 ---> 3412828192. but if i get 3412828159 ---> 203.107.144.0

Thank you

Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    [b][red]This message was edited by stober at 2002-9-23 5:29:31[/red][/b][hr]
    : I want to convert ip address to decimal number and reconvert it.
    :
    : Examples : If i get 203.107.160.32 ---> 3412828192. but if i get 3412828159 ---> 203.107.144.0
    :
    : Thank you
    :

    If you are trying to do socket stuff:
    char *host = "203.107.160.32";
    SOCKADDR_IN addr;
    addr.sin_family = AF_INET;
    addr.sin_port = port;
    addr.sin_addr.s_addr = inet_addr(host);



  • weiccoweicco Member Posts: 950
    : [b][red]This message was edited by stober at 2002-9-23 5:29:31[/red][/b][hr]
    : : I want to convert ip address to decimal number and reconvert it.
    : :
    : : Examples : If i get 203.107.160.32 ---> 3412828192. but if i get 3412828159 ---> 203.107.144.0
    : :
    : : Thank you
    : :
    :
    : If you are trying to do socket stuff:
    : char *host = "203.107.160.32";
    : SOCKADDR_IN addr;
    : addr.sin_family = AF_INET;
    : addr.sin_port = port;
    : addr.sin_addr.s_addr = inet_addr(host);
    :
    :
    :
    :

    This may look awful but it works :)

    DWORD dwIPAddr = 0;
    CHAR szIPAddr[16] = { 0 };

    // Dottet IP to number
    dwIPAddr = inet_addr("192.168.1.1");

    // Back to dottet form
    strcpy (szIPAddr, inet_ntoa(*((struct in_addr *)&dwIPAddr)));
  • Justin BibJustin Bib USAMember Posts: 0

    __ [ http://forcoder.org ] free ebooks and video tutorials about // Java Delphi R MATLAB Assembly Objective-C C++ Scratch JavaScript PL/SQL Ruby Visual Basic PHP Python Go Perl Visual Basic .NET C Swift C# Fortran D Awk Apex LabVIEW Scheme Clojure Logo Kotlin F# Prolog ABAP Lua Bash Erlang ML Julia FoxPro COBOL Lisp VBScript Ada Scala Transact-SQL Hack Crystal Dart Rust SAS Alice // ______________

Sign In or Register to comment.