When you have to specify an address for an WCF Endpoint using the NetTcpBinding, you have to specify a hostname:
Uri listenUri = new Uri("net.tcp://localhost:12564/");
ServiceHost sh = new ServiceHost(typeof(MyService), listenUri);
ServiceEndpoint ep = sh.AddServiceEndpoint(typeof(IMyService),
new NetTcpBinding(SecurityMode.None),
"MyService");
sh.Open();
As most bindings do, also the NetTcpBinding has a Property called
HostNameComparisonMode.
The default value
HostNameComparisonMode.StrongWildcard means that any host name (or ip) associated with
the computer described using the given hostname will match this endpoint (here: localhost)!
So in the example above, the Service will also be reachable via 192.168.23.42:12564 (given the "localhost" has this IP address).
(
via msdn magazine (german))