{"id":1410,"date":"2025-05-14T11:27:11","date_gmt":"2025-05-14T10:27:11","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1410"},"modified":"2025-05-14T11:27:11","modified_gmt":"2025-05-14T10:27:11","slug":"get-ip-address","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/tcp-ip\/networking-tcp-ip\/get-ip-address","title":{"rendered":"Get IP Address"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\tOurCurrentIpAddress = \"\";\n\n\tList&lt;NetworkingUtilities.NetworkAdapterInfo> NetworkAdapters = NetworkingUtilities1.GetNetworkInterfaceInformation_GetResult();\n\tif (NetworkAdapters != null)\n\t{\n\t\t\/\/----- LOOK FOR NETWORK ADAPTER THAT ARE CONNECTED -----\n\t\tforeach (NetworkingUtilities.NetworkAdapterInfo NetworkInfo in NetworkAdapters)\n\t\t{\n\t\t\tif (NetworkInfo.NetworkName != \"VirtualNetworkAdapter\")\n\t\t\t{\n\t\t\t\t\/\/This is a WiFi network adapter\n\t\t\t\t\/\/You can read:\n\t\t\t\t\/*\n\t\t\t\tNetworkInfo.NetworkName\n\t\t\t\tNetworkInfo.NetworkStatus\t\t\/\/&lt;ConnectionStatus. String, Can't find any explanations on possible values. \"InternetAccess\" is one\n\t\t\t\tif (NetworkInfo.NetworkIpv4.Length > 0)\n\t\t\t\t\tValues.Add(NetworkInfo.NetworkIpv4);\t\t\/\/&lt;IP address\n\t\t\t\telse\n\t\t\t\t\tValues.Add(NetworkInfo.NetworkIpv6);\n\t\t\t\t*\/\n\n\t\t\t\t\/*\n\t\t\t\tif (NetworkInfo.NetworkName != \"Ethernet\")\n\t\t\t\t{\n\t\t\t\t\t\/\/WiFi Adapter\n\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\/\/Ethernet Adapter\n\n\t\t\t\t}\n\t\t\t\t*\/\n\n\t\t\t\tif (NetworkInfo.NetworkIpv4.Length > 0)\n\t\t\t\t{\n\t\t\t\t\tOurCurrentIpAddress = NetworkInfo.NetworkIpv4;\n\t\t\t\t\tbreak;\t\t\t\t\/\/No point getting any more, we only care if there's at least one connected\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\n\n\t\t\/\/Get IP address operation completed\n\t\tif (OurCurrentIpAddress.Length > 0)\n\t\t{\n\t\t\t\/\/----- WE HAVE AN IP ADDRESS -----\n\t\t\t\/\/We have IP address so we are connected\n\n\t\t}\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159],"tags":[],"class_list":["post-1410","post","type-post","status-publish","format-standard","hentry","category-networking-tcp-ip"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1410"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1410\/revisions"}],"predecessor-version":[{"id":1411,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1410\/revisions\/1411"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}