Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
set socket [new_CkSocket]
# Populate a JsonObject with information about the local network adapters, including IPv4 addresses,
# IPv6 addresses, and MAC addresses.
set json [new_CkJsonObject]
set success [CkSocket_GetAdaptersAddresses $socket $json]
if {$success == 0} then {
puts [CkSocket_lastErrorText $socket]
delete_CkSocket $socket
delete_CkJsonObject $json
exit
}
CkJsonObject_put_EmitCompact $json 0
set jsonStr [CkJsonObject_emit $json]
puts "$jsonStr"
# JSON parsing code for this result can be generated at Chilkat's online tool:
# https://tools.chilkat.io/jsonParse
delete_CkSocket $socket
delete_CkJsonObject $json