Reference   Language | Libraries | Comparison | Changes

WiFiNINA : WiFi class

hostByName()

Description

Resolve the given hostname to an IP address

Syntax

WiFi.hostByName(hostname, result)

Parameters

hostname: Name to be resolved
result: IPAddress structure to store the returned IP address

Returns

1 if hostname was successfully converted to an IP address, else the error code

Example



  while (status != WL_CONNECTED) {
        Serial.print("Attempting to connect to SSID: ");
        Serial.println(ssid);
        status = WiFi.begin(ssid, pass);
        delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  IPAddress result;
  int err = WiFi.hostByName(server, result) ;
  if(err == 1){
        Serial.print("Ip address: ");
        Serial.println(result);
  } else {
        Serial.print("Error code: ");
        Serial.println(err);
  }



!!!!See Also



Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.