Sample code for 30+ languages & platforms
Lua

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 Lua Downloads

Lua
local chilkat = require("chilkat")

local socket = chilkat.Socket.new()

-- Populate a JsonObject with information about the local network adapters, including IPv4 addresses,
-- IPv6 addresses, and MAC addresses.
local json = chilkat.JsonObject.new()
local success = socket:get_adapters_addresses(json)
if not success then
    print(socket.last_error_text)
    return
end

json.emit_compact = false
local jsonStr = json:emit()
print(jsonStr)
-- JSON parsing code for this result can be generated at Chilkat's online tool:
-- https://tools.chilkat.io/jsonParse