Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
Interface - kodi::network

Network functions More...

Functions

bool kodi::network::WakeOnLan (const std::string &mac)
 Send WakeOnLan magic packet. More...
 
std::string kodi::network::GetIPAddress ()
 To the current own ip address as a string. More...
 
std::string kodi::network::URLEncode (const std::string &url)
 URL encodes the given string. More...
 
bool kodi::network::DNSLookup (const std::string &hostName, std::string &ipAddress)
 Lookup URL in DNS cache. More...
 

Detailed Description

Network functions

The network module offers functions that allow you to control it.

It has the header #include <kodi/Network.h> be included to enjoy it.

Function Documentation

◆ DNSLookup()

bool kodi::network::DNSLookup ( const std::string &  hostName,
std::string &  ipAddress 
)
inline

Lookup URL in DNS cache.

This test will get DNS record for a domain. The DNS lookup is done directly against the domain's authoritative name server, so changes to DNS Records should show up instantly. By default, the DNS lookup tool will return an IP address if you give it a name (e.g. www.example.com)

Parameters
[in]hostNameThe code of the message to get.
[out]ipAddressReturned address
Returns
true if successfull

Example:

#include <kodi/Network.h>
...
std::string ipAddress;
bool ret = kodi::network::DNSLookup("www.google.com", ipAddress);
fprintf(stderr, "DNSLookup returned for www.google.com the IP '%s', call was %s\n", ipAddress.c_str(), ret ? "ok" : "failed");
...
bool DNSLookup(const std::string &hostName, std::string &ipAddress)
Lookup URL in DNS cache.
Definition: addons/kodi-addon-dev-kit/include/kodi/Network.h:162

◆ GetIPAddress()

std::string kodi::network::GetIPAddress ( )
inline

To the current own ip address as a string.

Returns
Own system ip.

Example:

#include <kodi/Network.h>
...
std::string ipAddress = kodi::network::GetIPAddress();
fprintf(stderr, "My IP is '%s'\n", ipAddress.c_str());
...
std::string GetIPAddress()
To the current own ip address as a string.
Definition: addons/kodi-addon-dev-kit/include/kodi/Network.h:83

◆ URLEncode()

std::string kodi::network::URLEncode ( const std::string &  url)
inline

URL encodes the given string.

This function converts the given input string to a URL encoded string and returns that as a new allocated string. All input characters that are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version (NN where NN is a two-digit hexadecimal number).

Parameters
[in]urlThe code of the message to get.
Returns
Encoded URL string

Example:

#include <kodi/Network.h>
...
std::string encodedUrl = kodi::network::URLEncode("François");
fprintf(stderr, "Encoded URL is '%s'\n", encodedUrl.c_str());
...
std::string URLEncode(const std::string &url)
URL encodes the given string.
Definition: addons/kodi-addon-dev-kit/include/kodi/Network.h:122

For example, the string: François ,would be encoded as: FranC3A7ois

◆ WakeOnLan()

bool kodi::network::WakeOnLan ( const std::string &  mac)
inline

Send WakeOnLan magic packet.

Parameters
[in]macNetwork address of the host to wake.
Returns
True if the magic packet was successfully sent, false otherwise.