wut is the vb.net code for winsock1.LocalIp ?
Printable View
wut is the vb.net code for winsock1.LocalIp ?
Code:
Option Strict Off
Imports system
Imports System.Net.DNS
Public Class GetIP
Shared Function GetIPAddress() As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
With system.Net.DNS.GetHostByName(system.Net.DNS.GetHostName())
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
End With
GetIPAddress = sAddr
End Function
Shared Sub main()
Dim shostname As String
shostname = system.Net.DNS.GetHostName
console.writeline("Your Machine Name = " & shostname)
'Call Get IPAddress
console.writeline("Your IP = " & GetIPAddress)
End Sub
End Class
will that give you ur network ip or internet ip....bc this is how i get the network ip....
#Region "Private Declarations"
Private sLocalHost As String
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sLocalHost = System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList(0).ToString
MsgBox(sLocalHost, , "")
End Sub
Well the addresslist array is a listing of every ip address your computer has, network and internet one. Im not sure if array (0) always returns the internet one..i guess it may depend on which connects first...I cant really test the theory as my computer is just on one ip. The internet one.
you may want to experiment with that.
try changing the array's index to (1)...I wonder if it is possible to determine if the ip is local network assigned or internet..hmmm.
here is wut i did...and now i get my internet ip...
#Region "Private Declarations"
Private sLocalHost As String
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sLocalHost = System.Net.Dns.Resolve(System.Net.Dns.GetHostName()).AddressList(1).ToString
MsgBox(sLocalHost, , "")
End Sub
so how would i loop threw the indexs and add all of them to a listbox?