Bug 275 - Net.Tcp doesn't listen on or ::0
Summary: Net.Tcp doesn't listen on or ::0
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: master
Hardware: PC Linux
: Normal major
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2011-08-12 02:59 UTC by Stephen Kou
Modified: 2012-09-05 16:46 UTC (History)
4 users (show)

Tags: net.tcp listen address, WCF
Is this bug a regression?: ---
Last known good build:

Test case that repros issue (537 bytes, text/plain)
2011-08-13 06:03 UTC, Stephen Kou

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Stephen Kou 2011-08-12 02:59:04 UTC
On Microsoft's .NET, specifying an address of net.tcp://localhost:<port>/<path> causes WCF to listen on all addresses (  Specifying net.tcp://<port>/<path> forces it to listen on localhost only.  

I couldn't find a way to get Mono's WCF to listen on all addresses: "localhost" causes it to listen on, and "" throws an exception from Dns.GetHostEntry.

Perhaps in NetTcpListener.cs check to see if the hostname is 'localhost', then force it to be IPAddress.Any in the TcpListener creation?
Comment 1 Miguel de Icaza [MSFT] 2011-08-12 17:12:01 UTC
Again, a self-contained simple test case would get the effort moving a lot faster.
Comment 2 Stephen Kou 2011-08-13 06:03:20 UTC
Created attachment 119 [details]
Test case that repros issue

The following code listens on on ms.net/windows, but only on on mono/linux.
Comment 3 John Hargrove 2011-09-19 21:51:54 UTC
I had this issue as well. A workaround in the near-term is to use the computer's hostname. For example:

string uri = string.Format("net.tcp://{0}:5000/MyService", Dns.GetHostName());

This works for me. But yes, it should most certainly listen on IPAddress.Any (aka, see http://msdn.microsoft.com/en-us/library/system.net.ipaddress.any.aspx
Comment 4 Martin Baulig 2012-09-05 16:46:30 UTC
Fixed; mono master commit c99bb5c.