NetworkInterface Module

Used to obtain information about the computer's network interface.

Properties
IPAddress
MacAddress
SubnetMask

# Methods

None

# Notes

Use the GetNetworkInterface method of the System object to instantiate the NetworkInterface object. See the example.

REALbasic provides multiple network interface support for Windows, Mac OS X, and Linux. This allows you to write applications that can bind to different network interface cards on a user's machine. You can use this to write tunneling applications, for example.

To see what interfaces are installed on the user's machine, use the GetNetworkInterface method of the System object and assign the obtained interface object to the NetworkInterface property of the SocketCore class. When you do so, the socket will bind to that network interface.

# Example

The following simple example displays the IP address, Subnet mask, and Mac address for the selected network interface. At start-up the application detects all the network interfaces installed on the user's computer and loads them into a PopupMenu. The user then selects the desired network interface and the values are displayed in EditFields.

The PopupMenu's Open event handler is:

Dim i as Integer
For i = 0 to System.NetworkInterfaceCount-1
PopupMenu1.addRow Str(i)
Next

The Change event handler for the PopupMenu is this:

Dim n as NetworkInterface
//Get the NetworkInterface object for the selected item
n = System.GetNetworkInterface( Me.listIndex)
//Get the MAC Address
MacAddressField.Text = n.MACAddress
//Get the IP Address
IPAddressField.Text = n.IPAddress
//Get the Subnet Mask
SubnetMaskField.Text = n.SubnetMask

# See Also

System object; SocketCore, TCPSocket classes.