BandWidthTest.Program.GetPublicIpAddress C# (CSharp) Method

GetPublicIpAddress() private static method

private static GetPublicIpAddress ( ) : string
return string
        private static string GetPublicIpAddress()
        {
            var request = (HttpWebRequest)WebRequest.Create("http://checkip.dyndns.org/");
            string publicIPAddress;
            request.Method = "GET";
            using(WebResponse response = request.GetResponse()) {
                using(var reader = new System.IO.StreamReader(response.GetResponseStream())) {
                    publicIPAddress = reader.ReadToEnd();
                }
            }
            string addr = publicIPAddress.Split(new char[] { ':' })[1].Split(new char[] { '<' })[0];
            return addr.Trim();
        }