Forum Discussion
hooleylist
Feb 08, 2010Cirrostratus
I think the poster is trying to convert the client IP to a decimal value, along the lines of the PHP ip2long function. I was playing around with such a conversion in TCL, but it seems to overflow a 2^32 integer:
This works. Returns 2130706433
set ip 127.0.0.1
This works. Should return 377299345
set ip 22.125.33.145
This does not work. Should return 4211081210
set ip 250.255.255.250
scan $ip {%d.%d.%d.%d} a b c d
set dec [expr {[expr {$a <<24}] + [expr {$b <<16}] + [expr {$c <<8}] + $d }]
Anyone have suggestions on converting a dotted IP address to decimal format?
Aaron