Getting your dynamic public IP in C# & .net
This code makes a HTTP request to network-tools.com and retrieves the IP from the response.
string URL = "http://www.network-tools.com";
HttpWebRequest HWR = (HttpWebRequest)HttpWebRequest.Create(URL);
HWR.Method = "GET";
StreamReader SR = new StreamReader(HWR.GetResponse().GetResponseStream());
string Response = SR.ReadToEnd();
string Pattern = @"dd?d?.dd?d?.dd?d?.dd?d?";
Regex R = new Regex(Pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase);
Match M = R.Match(Response);
string IP = M.ToString();
HttpWebRequest and HttpWebResponse are two very useful classes in .NET. I will recommened reading up on this and I will soon blog about them again.
- Mixing Assembly language with Visual Basic
- Who is WHOIS?
- RAID 1 vs RAID 5
- Do all versions of OpenCV run at the same speed?
- Color-based Blob Detection
- Hardware Platforms for Embedded Computer Vision, Image Processing and Deep Learning
- Motivation for hand-optimized Assembly code
- My experience running PHP on IIS 7.5
- Scripting form post in C# & .net
- Color Conversions