|
-
Apr 22nd, 2002, 02:22 PM
#1
Thread Starter
Addicted Member
Simple Question...
wut is the vb.net code for winsock1.LocalIp ?
-
Apr 22nd, 2002, 02:49 PM
#2
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
-
Apr 22nd, 2002, 03:05 PM
#3
Thread Starter
Addicted Member
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
-
Apr 22nd, 2002, 03:08 PM
#4
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.
-
Apr 22nd, 2002, 03:10 PM
#5
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.
-
Apr 22nd, 2002, 03:19 PM
#6
Thread Starter
Addicted Member
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
-
Apr 22nd, 2002, 03:50 PM
#7
Thread Starter
Addicted Member
so how would i loop threw the indexs and add all of them to a listbox?
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
|