Xbase++
Xbase++
Get Local Network Adapter Addresses
See more Socket/SSL/TLS Examples
Demonstrates Socket.GetAdaptersAddresses, which populates a JsonObject with information about local network adapters, including IPv4 addresses, IPv6 addresses, and MAC addresses.
Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.
Background. This provides a portable way to enumerate the host's network interfaces and their addresses.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oSocket
LOCAL oJson
LOCAL cJsonStr
nSuccess := 0
oSocket := CreateObject("Chilkat.Socket")
// Populate a JsonObject with information about the local network adapters, including IPv4 addresses,
// IPv6 addresses, and MAC addresses.
oJson := CreateObject("Chilkat.JsonObject")
nSuccess := oSocket:GetAdaptersAddresses(oJson)
IF (nSuccess == 0)
? oSocket:LastErrorText
oSocket:destroy()
oJson:destroy()
RETURN
ENDIF
oJson:EmitCompact := 0
cJsonStr := oJson:Emit()
? cJsonStr
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
oSocket:destroy()
oJson:destroy()