|
-
Feb 25th, 2009, 04:14 PM
#1
Thread Starter
Banned
[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
-
Feb 25th, 2009, 04:29 PM
#2
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.
-
Feb 25th, 2009, 04:41 PM
#3
Thread Starter
Banned
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
?
-
Feb 25th, 2009, 05:12 PM
#4
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
-
Feb 25th, 2009, 05:12 PM
#5
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"))
-
Feb 25th, 2009, 05:34 PM
#6
Thread Starter
Banned
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
-
Feb 25th, 2009, 05:54 PM
#7
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
 
-
Feb 25th, 2009, 06:24 PM
#8
Thread Starter
Banned
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
-
Feb 25th, 2009, 06:35 PM
#9
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.
-
Feb 26th, 2009, 03:42 PM
#10
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|