Results 1 to 7 of 7

Thread: Simple Question...

  1. #1

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196

    Simple Question...

    wut is the vb.net code for winsock1.LocalIp ?

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    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

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    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

  7. #7

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    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
  •  



Click Here to Expand Forum to Full Width