PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Socket
oleobject loo_Json
string ls_JsonStr
li_Success = 0
loo_Socket = create oleobject
li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket")
if li_rc < 0 then
destroy loo_Socket
MessageBox("Error","Connecting to COM object failed")
return
end if
// Populate a JsonObject with information about the local network adapters, including IPv4 addresses,
// IPv6 addresses, and MAC addresses.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Socket.GetAdaptersAddresses(loo_Json)
if li_Success = 0 then
Write-Debug loo_Socket.LastErrorText
destroy loo_Socket
destroy loo_Json
return
end if
loo_Json.EmitCompact = 0
ls_JsonStr = loo_Json.Emit()
Write-Debug ls_JsonStr
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
destroy loo_Socket
destroy loo_Json