New constructor for TCPListener

New constructor for TCPListener

Post by Sm9uIEphY2 » Thu, 16 Aug 2007 21:24:04


I use in vb (VS2005)

Server = New TcpListener(PortNumber)

Which is simple and straightforward. But I get
Public Sub New(port As Integer) is obsolete: This method has been
deprecated. Please use TcpListener(IPAddress localaddr, int port) instead.

It also gives a link that returns "page not found."

If I use the new constructor, what values do I give it so that it behaves
the same as the old constructor?
I guess the port number would be the same, but what in the world should I
put as the IPAddress?

The scenario is this: First I deploy the app as a service on my development
machine and put the TCP communications through its paces, from apps on my
machine and other machines.
Next I uninstall it from my machine and install it on a test server, and put
it through the same tests.
Finally, I uninstall it from the test server and install it on the
production server. etc.

This should all work without changing any code in the program or the
contents of any files it reads, and without recompiling the program.

I can do this with the "obsolete" constructor. What do I use for IPAddress
so it works the same way with the new constructor?
 
 
 

New constructor for TCPListener

Post by Henning Kr » Thu, 16 Aug 2007 23:15:54

Hello,

if you use IPAddress.Any, it will bind to all available addresses on the
machine.

Kind regards,
Henning Krause

 
 
 

New constructor for TCPListener

Post by Sm9uIEphY2 » Thu, 16 Aug 2007 23:30:00

> if you use IPAddress.Any, it will bind to all available addresses on the
Excellent. Thank you