Declaring a IPAddress as localhost

How do I dim ipa as ipaddress = "127.0.0.1" 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

LVL 1
addicktzAsked:
Who is Participating?
 
ankur313Commented:
There are a number of ways of doin this.

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

         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 "127.0.0.1" and vice versa for option one above.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.