Tag Archives: ip
How to get your IP in C#
There are two ways of getting your IP address in C#. One of them is by using the methods provided by the .NET framework and the other one by using a third party api.
What is the difference you might ask. The answer is fairly simple. There are two kinds of IP’s, internal IP’s and external IP’s. Sadly the .NET framework methods are not able to retrieve the external IP if the computer is not directly connected to the internet (no router or any other similar devices). Since this limitation exists there is only one option if you wish to get the external IP, and this is by using an online service.
I’ve constructed two methods below. One uses only the .NET framework methods but is not 100% accurate when trying to retrieve the external IP (requires the system to be directly connected to the internet). The second method uses an online service which should have fairly accurate results as long as the service is online and the computer is not behind a proxy.
Method 1
LINQ approach
1 2 3 4 5 6 | IPAddress localAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); if (localAddress != null) { // do something with localAddress } |
Non-LINQ approach (for .NET framework versions before 3.5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | IPAddress localAddress = null; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == AddressFamily.InterNetwork) { localAddress = address; break; } } if (localAddress != null) { // do something with localAddress } |
Method 2
1 2 3 4 5 6 7 8 9 10 | string ipAddress; using (WebClient wc = new WebClient()) { ipAddress = wc.DownloadString("http://icanhazip.com/"); } if (!string.IsNullOrEmpty(ipAddress)) { // do something with ipAddress } |
ProxyChecker++ released!
If you are one of those people that value their on-line privacy then at some point you probably looked for a way to hide your true IP from being tracked by various websites. ProxyChecker++ is the tool that will make your life easier and will help you achieve what you are looking for much faster.
Although ProxyChecker++ itself won’t provide you with proxies to use, it will help you find which ones are actually working or not so that you won’t have to waste countless hours trying to figure it out on your own.
Note: This is only the core program for handling the proxy checking, more features will follow in the near future.
Download FilePosted in Software Releases.
Tagged C#, csharp, fluxbytes, fluxbytes software, ip, privacy, proxies