Get IP Address
Posted: Sun Nov 07, 2021 11:16 am
seems your platform setting is != "x86"
regards
Karl-Heinz
regards
Karl-Heinz
Code: Select all
using System.Net.NetworkInformation
USING System.Net.Sockets
PUBLIC CLASS NetworkTools
PUBLIC STATIC METHOD GetAllIPv4(netType AS NetworkInterfaceType ) AS List<STRING>
RETURN (;
FROM x IN ;
(;
FROM x IN NetworkInterface.GetAllNetworkInterfaces();
WHERE (x:NetworkInterfaceType == netType) .AND. (x:OperationalStatus == OperationalStatus.Up);
SELECT x;
);
:SelectMany({x AS NetworkInterface => x:GetIPProperties():UnicastAddresses});
WHERE x:Address:AddressFamily == AddressFamily.InterNetwork;
SELECT x:Address:ToString();
):ToList()
PUBLIC STATIC METHOD GetAllLocalIPv4() AS List<STRING>
LOCAL allLocalIPv AS List<STRING>
// Wired
allLocalIPv := GetAllIPv4(NetworkInterfaceType.Ethernet)
// Wifi
allLocalIPv:AddRange(GetAllIPv4(NetworkInterfaceType.Wireless80211))
RETURN allLocalIPv
END CLASS
Code: Select all
VAR IPs := NetworkTools.GetAllLocalIPv4()
FOREACH VAR ip IN IPs
? ip
NEXT