NetworkHost QML Type

Provides static functions for host name lookups. More...

Import Statement: import ArcGIS.AppFramework.Networking 1.0



Detailed Description

The NetworkHost component uses the lookup mechanisms provided by the operating system to find the IP address(es) associated with a host name, or the host name associated with an IP address.

This code sample demonstrates usage of the NetworkHost component. Pressing the button created by this sample will display information about a machine or IP address entered into the provided text area.

Item {
        property alias machineName: textField.text

        ColumnLayout {
                anchors.fill: parent
                anchors.margins: 10

                spacing: 10

                TextField {
                        id: textField
                        selectByMouse: true
                        Layout.fillWidth: true
                        placeholderText: qsTr("Enter machine name or an ip address")
                        onAccepted: lookupMachineName()

                Button {
                        text: qsTr("Lookup")
                        enabled: machineName.length > 0
                        onClicked: lookupMachineName()

                Flickable {
                        Layout.fillWidth: true
                        Layout.fillHeight: true

                        flickableDirection: Flickable.VerticalFlick
                        contentHeight: textArea.height
                        clip: true

                        TextArea {
                                id: textArea
                                width: parent.width
                                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
                                selectByMouse: true

        NetworkHost {
                id: networkHost
                onAddressesChanged: listAddresses()

        function textArea_log(str) {
                textArea.text = textArea.text + str + "\n";

        function lookupMachineName() {
                textArea_log(qsTr("Lookup %1 ...").arg(machineName));

        function listAddresses() {
                for (var i in networkHost.addresses) {
                        var networkAddress = networkHost.addresses[i];
                        textArea_log("Host name is " + networkHost.hostName);
                        textArea_log("Address is " + networkAddress.address);
                        textArea_log("Protocol is " + networkAddress.protocol);
                        textArea_log("isMulticast is " + networkAddress.isMulticast.toString());
                        textArea_log("isLoopback is " + networkAddress.isLoopback.toString());

Property Documentation

[read-only] addresses : List<NetworkAddress>

Returns a list of valid network addresses.

autoLookup : bool

If true, automatically executes the lookup method when the hostname is set.

hostName : string

Returns the name of the host whose IP addresses were looked up.

Method Documentation


Looks up the IP address or addresses associated with the given host name or vice versa, and returns an ID for the lookup. This is an asynchronous operation. To get the network addresses, use the onAddressesChanged signal.

The hostName parameter

The host name to find associated IP addresses for.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.