This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Get longip

Old posts that have not been replied to for several years.
Locked
M
Martin

Get longip

Post by Martin »

Is it posseble to creat a long ip from a normal ip like 192.168.0.1 to 3232235521? same as $longip in mirc.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Yes, it's essentially 2 lines of tcl.

Code: Select all

# Assuming $ip contains your dotted-decimal ip address
regexp {^(\d*).(\d*).(\d*).(\d*)$} $ip ignore a b c d
set long [expr ($d << 24) + ($c << 16) + ($b << 8) + $a]
I think that's right anyway.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Uhh, I guess maybe it's

set long [expr ($a << 24) + ($b << 16) + ($c << 8) + $d]

I thought the bytes were reversed for some reason.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It's ages since I seen some conversion code.

I think you reverse the bytes when doign long2ip.
Locked