Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IP numbers
Message
From
22/04/2011 09:01:34
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
21/04/2011 19:29:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01508084
Message ID:
01508122
Views:
57
>I've been trying to use incrementing ip numbers to access the web.
>Here's a bit of code with which I've been noodling.
>
>
>A = 75
>B = 124
>C = 92
>D = 71
>D = D + 1
>IF D > 255
>D = 1
>C = C + 1
>ENDIF
>IF C > 255
>C = 1"
>B = B + 1
>ENDIF
>IF B > 255
>B = 1
>A = A + 1
>ENDIF
>IF A > 255
>QUIT
>ENDIF
>IPOutput = "HTTP://" + A + "." + B + "." + C + "." + D
>IPOutput = ALLTRIM(IPOutput)
>
>
>I'm trying to mix numbers and strings to come up with a working IP. Any ideas? or solutions? appreciated.

Of course in the concatenation (the second-last line), numbers must be converted to text - I suggest transform(A) + ... for simplicity.

If you replace A, B, C, D with a single array, you can replace several IF structures with a single loop (plus a final exit condition).

Please note that the entire range of addresses is quite large - 2^32, or about 4.3 billion addresses. That is, if you go ahead and generate ALL IP addresses, it will take quite a while.

Also, out of these addresses, some are not usable. Mainly, the entire Class D and Class E range are not used to access individual computers. (Class D is used for multicasting, Class E is reserved for experimental purposes.) That makes the upper limit for usable IP addresses 223.255.255.255.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform