Results 1 to 5 of 5

Thread: Get host's IP

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Get host's IP

    I was looking around how to get a host's IP, this is the code I found. Thought might be useful to someone.

    vb.net Code:
    1. Public Sub GetHostsIP()
    2.         Dim i As Integer
    3.         Dim ipE As IPHostEntry = Dns.GetHostEntry("HostName")
    4.         Dim IpA() As IPAddress = ipE.AddressList
    5.         For i = 0 To IpA.GetUpperBound(0)
    6.             Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString)
    7.         Next
    8.         Console.WriteLine("Press any key to close")
    9.         Console.ReadKey(True)
    10. End Sub
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  2. #2
    Member
    Join Date
    Jun 2009
    Posts
    34

    Re: Get host's IP

    thnx i need this

  3. #3
    Banned
    Join Date
    Jun 2009
    Posts
    12

    Re: Get host's IP

    it scan ips ??

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Get host's IP

    Quote Originally Posted by SoulCollector View Post
    it scan ips ??
    No. It just resolves the given hostname using DNS and returns the IP's associated with it.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: Get host's IP

    SoulCollector check out this thread to get hostnames, then you just have to resolve the host's name to get the IP.

    Hope it helps
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width