I posted a variant of this question on a thread earlier today, but it got lost in the shuffle and so far the messages posted after mine were orthogonal to my question.
I realize everyone knows this, but I'll go through it to set up the problem.
In a "HOST ADDR TO Temp" statement, you get the primary IP address of the machine placed in Temp. If you have more than one IP address assigned to the machine, you'll only get the first one with that version of the HOST ADDR statement. OK, fine. We all know that if you have two ethernet cards, or say one and have an active modem, there will be two IP addresses, and you can get them by doing:
HOST ADDR 1 TO Temp1
HOST ADDR 2 TO Temp2
The "1" and "2" are the index. The index is the key.
Here is my question: How do you enumerate the valid range of the index if you need to know ALL of the IP addresses for the machine, but your application will not have a clue ahead of time how many the machine it is running on might have?
I did a simple experiment hoping I could simply advance the index until a trappable error occurred. No such luck.. If you exceed the index's valid range, you get a bunch of nonvalid IP addresses (as far as I can tell), and then a General Protection Fault.
For example, in my machine right now I have two ethernet cards and a (inactive) modem.
If I run this code (suitably inserted in the correct PB trappings):
FOR Index& = 1 TO 10
HOST ADDR (Index&) TO Temp
IF ERR THEN GOTO Outloop
#DEBUG PRINT IpToString(Temp)
NEXT Index&
Outloop:
I trigger a General Protection Fault when Index&=6.
The DEBUG window displays
24.13.211.16
192.168.0.1
107.98.46.110
101.46.109.101
100.105.97.111
The first two IP addressess (24.13.211.16, 192.168.0.1) are correct. That last 3 are junk as far as I can tell.
So does anyone know how if I have no prior knowledge of how many IP addresses the machine my application will be running in should have, but I need to know ALL of them, how can I ascertain the valid range for Index& ?
(As an aside, I do know how to enumerate & list all the valid MAC addresses in a machine, but aside from doing all that work to just to get an index range for enumerating all the IP addresses, the number of valid MAC addresses won't always match the number of valid IP addresses.)
------------------
I realize everyone knows this, but I'll go through it to set up the problem.
In a "HOST ADDR TO Temp" statement, you get the primary IP address of the machine placed in Temp. If you have more than one IP address assigned to the machine, you'll only get the first one with that version of the HOST ADDR statement. OK, fine. We all know that if you have two ethernet cards, or say one and have an active modem, there will be two IP addresses, and you can get them by doing:
HOST ADDR 1 TO Temp1
HOST ADDR 2 TO Temp2
The "1" and "2" are the index. The index is the key.
Here is my question: How do you enumerate the valid range of the index if you need to know ALL of the IP addresses for the machine, but your application will not have a clue ahead of time how many the machine it is running on might have?
I did a simple experiment hoping I could simply advance the index until a trappable error occurred. No such luck.. If you exceed the index's valid range, you get a bunch of nonvalid IP addresses (as far as I can tell), and then a General Protection Fault.
For example, in my machine right now I have two ethernet cards and a (inactive) modem.
If I run this code (suitably inserted in the correct PB trappings):
FOR Index& = 1 TO 10
HOST ADDR (Index&) TO Temp
IF ERR THEN GOTO Outloop
#DEBUG PRINT IpToString(Temp)
NEXT Index&
Outloop:
I trigger a General Protection Fault when Index&=6.
The DEBUG window displays
24.13.211.16
192.168.0.1
107.98.46.110
101.46.109.101
100.105.97.111
The first two IP addressess (24.13.211.16, 192.168.0.1) are correct. That last 3 are junk as far as I can tell.
So does anyone know how if I have no prior knowledge of how many IP addresses the machine my application will be running in should have, but I need to know ALL of them, how can I ascertain the valid range for Index& ?
(As an aside, I do know how to enumerate & list all the valid MAC addresses in a machine, but aside from doing all that work to just to get an index range for enumerating all the IP addresses, the number of valid MAC addresses won't always match the number of valid IP addresses.)
------------------
Comment