Results 1 to 10 of 10

Thread: [RESOLVED] How To Find IP

  1. #1

    Thread Starter
    Banned
    Join Date
    Jan 2009
    Posts
    144

    Resolved [RESOLVED] How To Find IP

    Yes I Was wounder How Would I use System.Net.Sockets To Find my IP ....
    And Then In A Separate code How Would I Make an IP changer


    What Im I making?:
    +Im Making A Program That Tells You Your IP..and then There Will Be an Option To Change It


    -----------------------------Plus----------------------------------------

    If anyone no's about Computers .....I Want to No Y when I made An IP Thing in VB6 (using Winsock) That It Shows Me a Different Ip Then From http://whatsmyip.org/? { Like IT Gives Me a Diffrent Number Then The VB IP program??
    ______________________________________________________________--
    THX

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: How To Find IP

    Whatismyip.org shows you your external IP address. Unless your computer is connected directly to the internet (i.e. no router), any code you run that only looks at the local machine can only give your your internal address.

    If you want to be sure to always get the external IP, you will have to use an external service like whatismyip.

    As for changing that IP address, that is very dependent on the internet connection that is being used and how the IP address is obtained.

  3. #3

    Thread Starter
    Banned
    Join Date
    Jan 2009
    Posts
    144

    Re: How To Find IP

    ooooooo...I seee!! oo... thx!! I been woundering That for The longest...But Would You No How To Use System.Net.Sockets To Find My external Ip
    ?

  4. #4
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: How To Find IP

    You can look your IP up this way;

    Code:
        Public Function GetExternalIP() As String
            Dim IP_URL As String = "http://checkip.dyndns.org"
            Dim strHTML, strIP As String
            Try
                Dim objWebReq As System.Net.WebRequest = System.Net.WebRequest.Create(IP_URL)
                Dim objWebResp As System.Net.WebResponse = objWebReq.GetResponse()
                Dim strmResp As System.IO.Stream = objWebResp.GetResponseStream()
                Dim srResp As System.IO.StreamReader = New System.IO.StreamReader(strmResp, System.Text.Encoding.UTF8)
                strHTML = srResp.ReadToEnd()
                Dim regexIP As System.Text.RegularExpressions.Regex
                regexIP = New System.Text.RegularExpressions.Regex("\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b")
                strIP = regexIP.Match(strHTML).Value
                Return strIP
            Catch ex As Exception
                MessageBox.Show("Can't retrieve external IP: " & ex.Message)
                Return Nothing
            End Try
        End Function

  5. #5
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: How To Find IP

    Technically, you could use the webclient.DownloadString() on whatismyip.org to get the IP address. If you were looking to do this very frequently or for a lot of users, you should probably contact the web site to make sure they are OK with you doing that.

    Code:
            Dim wc As New System.Net.WebClient()
            MessageBox.Show(wc.DownloadString("http://whatismyip.org"))

  6. #6

    Thread Starter
    Banned
    Join Date
    Jan 2009
    Posts
    144

    Re: How To Find IP

    oo ok ...Ok So like Im Gonna Have a Textbox And a Button ANd Once I click The Button I want it To Like Show The Ip SO instead of "Messagebox.show"
    Can I Put textbox1?...And Is there A Winsock Method
    Because I Have winsock For Visual basic 2008

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: How To Find IP

    I think what they are saying is that there may not be a Winsock method that will do this, but it depends on how you connect to the internet. If you are connecting over a LAN, or through a router (I make that distinction for a reason, but I won't go into it), then Winsock will give you the wrong IP address.

    So before you go further, how are you connecting to the internet?
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    Banned
    Join Date
    Jan 2009
    Posts
    144

    Re: How To Find IP

    ooo By LAN...But Like I Im trying To Make A Ip program for Both..I just need sumone to like push me in the right direction on how to make it and stuff

  9. #9
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: How To Find IP

    Get you local IP using;

    Code:
            'Using Imports System.Net.dns at the top of your file
    
            Dim IpAddr() As Net.IPAddress = GetHostEntry(GetHostName()).AddressList
            For i As Integer = 0 To IpAddr.Length - 1
                MessageBox.Show(IpAddr(i).ToString)
            Next
    and your external IP in the way I showed in post #4.

  10. #10
    Lively Member
    Join Date
    Feb 2009
    Posts
    66

    Re: [RESOLVED] How To Find IP

    thank you for the help i need help on the same thing

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