|
-
Mar 1st, 2006, 06:57 AM
#1
Thread Starter
Hyperactive Member
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
-
Mar 1st, 2006, 02:02 PM
#2
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
-
Mar 1st, 2006, 03:24 PM
#3
Frenzied Member
Re: converting IP address to IP number
String s = ip_address;
StringTokenizer st = new StringTokenizer(s,'.');
//lloop and create a new string
-
Mar 2nd, 2006, 09:40 PM
#4
Re: converting IP address to IP number
 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
-
Mar 3rd, 2006, 06:09 AM
#5
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|