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

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

0
addicktz
Asked:
addicktz
1 Solution
 
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

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