Results 1 to 5 of 5

Thread: converting IP address to IP number

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    277

    converting IP address to IP number

    hi hi..

    how can i convert an IP address to an IP number?

    Example from IP address :192.168.0.1 to <ip no>

    ???
    ocw

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: converting IP address to IP number

    -cast each byte into a char
    -create a string
    -remove the dots '.'
    -parse long
    and there is your IP number "I've never heard about this idea"
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: converting IP address to IP number

    String s = ip_address;

    StringTokenizer st = new StringTokenizer(s,'.');

    //lloop and create a new string

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: converting IP address to IP number

    Quote Originally Posted by System_Error
    String s = ip_address;

    StringTokenizer st = new StringTokenizer(s,'.');

    //lloop and create a new string
    You only get IP addresses as Array of bytes so I think my way is better
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: converting IP address to IP number

    Probably. Just now remembered they were byte arrays when you said that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width