There is a command to get the IP address of every network adapter of a specified host computer. If you specify no host name, it will report the host adapter info of the computer running the program. CountHostIPs is the command for retrieving the adapter info, which returns the number of host adapters present. Each adapter's IP can then be accessed using HostIP(n).
This routine will evaluate all host adapters on the computer running it and store them in an array, giving you:
hadapters - number of network adapters on the computer
ips(n) - IP address, in integer form, of network adapter n.
Note that in the instance there is no adapter, CountHostIPs will report back one adapter, and it's IP will be 2130706433 (127.0.0.1), the internal loopback IP. If your first IP is reported as that, you can make the assumption the machine running the program has no network connection.
To determine another computer's IP from yours, you will need to know the host name of the other computer, and change CountHostIPs("") to CountHostIPs("othercomp"), where othercomp is the host name of the, er, other comp. Then the routine will return the IP of every adapter available to your computer from the other (which may not necessarily be every adapter on the other computer).
If the host name of the other computer is unknown, you'll have to get the other computer to send you a packet, then you can retreive the source IP of the received packet.
hadapters = CountHostIPs("") Dim ips(hadapters) For x = 1 To hadapters ips(x) = HostIP(x) Print "Adapter "+x+" IP is "+DottedIP$(ips(x)) Next WaitKey()
This routine will evaluate all host adapters on the computer running it and store them in an array, giving you:
hadapters - number of network adapters on the computer
ips(n) - IP address, in integer form, of network adapter n.
Note that in the instance there is no adapter, CountHostIPs will report back one adapter, and it's IP will be 2130706433 (127.0.0.1), the internal loopback IP. If your first IP is reported as that, you can make the assumption the machine running the program has no network connection.
To determine another computer's IP from yours, you will need to know the host name of the other computer, and change CountHostIPs("") to CountHostIPs("othercomp"), where othercomp is the host name of the, er, other comp. Then the routine will return the IP of every adapter available to your computer from the other (which may not necessarily be every adapter on the other computer).
If the host name of the other computer is unknown, you'll have to get the other computer to send you a packet, then you can retreive the source IP of the received packet.