Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Resolving hostname through a proxy server

Resolving hostname through a proxy server

Scheduled Pinned Locked Moved Visual Basic
csharphtmldatabasecom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fu Manchu
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups