Resolving hostname through a proxy server
-
Hi, I wonder if someone has the knowledge I lack, I am trying to resolve a hostname through a proxy server in vb.net but I am figure out how to combine these subroutines? This sub is to give a proxy server some credentials and download the html from the page Warning **** imports system.net at top of code **** Private Sub Myproxy() Dim result As String = "" Try Dim proxy As WebProxy = New WebProxy("http://proxy:80/", True) proxy.Credentials = New NetworkCredential("username", "password", "domain.com") Dim request As WebRequest = WebRequest.Create("http://www.c-sharpcorner.com") request.Proxy = proxy Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse) Dim stream As System.IO.Stream = response.GetResponseStream Dim ec As System.Text.Encoding = System.Text.Encoding.GetEncoding("utf-8") Dim reader As System.IO.StreamReader = New System.IO.StreamReader(stream, ec) Dim chars(256) As Char Dim count As Integer = reader.Read(chars, 0, 256) While count > 0 Dim str As String = New String(chars, 0, 256) result = result + str count = reader.Read(chars, 0, 256) End While RichTextBox1.Text = result response.Close() stream.Close() reader.Close() Catch exp As Exception Dim str As String = exp.Message End Try End Sub This is the sub to resolve the hostname Public Sub DisplayHostAddress(ByVal hostString As [String]) Try Dim hostInfo As IPHostEntry = Dns.Resolve(hostString) ' Get the IP address list that resolves to the host names contained in the Alias ' property. Dim address As IPAddress() = hostInfo.AddressList ' Get the alias names of the addresses in the IP address list. Dim [alias] As [String]() = hostInfo.Aliases MsgBox(("Host name : " + hostInfo.HostName)) 'MsgBox(ControlChars.Cr + "Aliases : ") Dim index As Integer For index = 0 To [alias].Length - 1 MsgBox([alias](index)) Next index 'MsgBox(ControlChars.Cr + "IP Address list :") For index = 0 To address.Length - 1 MsgBox(Convert.ToString(address(index))) Next index Catch e As