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.
Old posts that have not been replied to for several years.
M
Martin
Post
by Martin » Wed Nov 13, 2002 12:13 pm
Is it posseble to creat a long ip from a normal ip like 192.168.0.1 to 3232235521? same as $longip in mirc.
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Wed Nov 13, 2002 6:42 pm
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.
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Wed Nov 13, 2002 6:51 pm
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.
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Thu Nov 14, 2002 6:09 am
It's ages since I seen some conversion code.
I think you reverse the bytes when doign long2ip.