• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1467
  • Last Modified:

Declaring a IPAddress as localhost

How do I dim ipa as ipaddress = "" or how do I make an ipendpoint that represents my localhost, port ?

dim tcpl as tcplistener
tcpl = new tcplistener(port) does not work, and is said to be obsolete by vs.net 2003

1 Solution
There are a number of ways of doin this.

1.) This is one:
         Dim port As Int32 = 13000
         Dim localAddr As IPAddress = IPAddress.Parse("")

         Dim server As New TcpListener(localAddr, port)

2.) This is second:
tcpListener = New TcpListener(CType(Dns.Resolve("machineName").AddressList(0), IPAddress), port)

You can replace "machineName" by "" and vice versa for option one above.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now