[Mono-list] TcpChannel constructor throws SocketException with DHCP on Mac OS X

Robert Smallshire robert at smallshire.org.uk
Sat Jul 14 05:59:42 EDT 2007

The following program, which simply constructs a TcpChannel object fails on
Mono 1.2.4 with a SocketException.

using System.Runtime.Remoting.Channels.Tcp;
namespace Test {
    class Program {
        static void Main(string[] args) {
            TcpChannel channel = new TcpChannel(1234);

Unhandled Exception: System.Net.Sockets.SocketException: No such host is
  at System.Net.Dns.hostent_to_IPHostEntry (System.String h_name,
System.String[] h_aliases, System.String[] h_addrlist) [0x00000] 
  at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] 
  at System.Net.Dns.Resolve (System.String hostName) [0x00000] 
  at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.Init
(IServerChannelSinkProvider serverSinkProvider) [0x00000] 
  at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor
(IDictionary properties, IServerChannelSinkProvider serverSinkProvider)
  at System.Runtime.Remoting.Channels.Tcp.TcpChannel.Init (IDictionary
properties, IClientChannelSinkProvider clientSink,
IServerChannelSinkProvider serverSink) [0x00000] 
  at System.Runtime.Remoting.Channels.Tcp.TcpChannel..ctor (Int32 port)
  at TamGeoTest.Program.Main (System.String[] args) [0x00000]

The problem is that GetHostByName fails with 'No such host is known' when my
Mac is configured to use DHCP. If I add an explicit entry for my hostname
and IP address into /etc/hosts then it works fine.

The same code works fine on .NET on Windows with DHCP assigned addresses,
and works fine with static IP addresses. So, first of all, how do I
construct a TcpChannel in the precense of DHCP assigned addresses, and
secondly is this a bug in the Mono implementation, given that it works under
.NET ?

Many thanks,


More information about the Mono-list mailing list