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.

Was it helpful?

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top