[Mono-list] IPEndPoint/Socket.Bind behaviour

Symon Chalk symonc@mac.com
Tue, 5 Apr 2005 16:18:50 +0100


I'm developing a multi-homed server app. that has to listen for 
broadcast UDP. I've tried the following:

EndPoint local = new IPEndPoint(ip, port);
   .
   .
   .
listen.Bind(local);

Where "ip" is an IPAddress with a parsed address or hostname and 
"listen" is a Socket instantiated with SocketType.Dgram, 
ProtocolType.Udp. However, this endpoint never receives any data. 
Changing the code to:

new IPEndPoint(IPAddress.Any, port);

works, but this means that you can't have multiple listeners without a 
SetSocketOption(SocketOptionLevel.Socket, 
SocketOptionName.ReUseAddress, 1) call.

I've tried the same code in .NET and it works in the original 
configuration, i.e.  as:

EndPoint local = new IPEndPoint(ip, port)

For the time being the SetSocketOption workaround is sufficient as all 
interfaces are in the same address range, however I can't see how this 
would work with different address ranges.

Can anyone shed on light on this?

Thanks,

Symon.

--

"Always acknowledge a fault. This will throw those in authority off 
their guard and give you an opportunity to commit more."

-- Mark Twain