Question

I have two network interfaces. I take 192.168.1.100 from eth0 and 192.168.1.227 from eth0. Which nic does my tcp listener listen when i use the code below:

tcpListener = new TcpListener(IPAddress.Any, 1234);
tcpListener.Start();

Gateway and subnet mask configurations are different for each nic also.

Était-ce utile?

La solution

new TcpListener(IPAddress.Any, 1234) initializes a new listener that listens for incoming connection attempts on the specified local IP address and port 1234. In your case represents IPAddress.Any all local IP addresses.

I hope this will answer your question.

You can find more information here: http://msdn.microsoft.com/library/vstudio/system.net.sockets.tcplistener

Autres conseils

It's binding to all IP addresses on your computer, not necessarily all NICs, as this will also bind to local loopback, along with any virtual adapters you may have.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top