[Mono-list] Porting UPnP Tools to MONO - Socket "ExclusiveAddressUse" problem
Alan McGovern
alan.mcgovern at gmail.com
Mon May 10 18:57:02 EDT 2010
I don't think this is supported on linux, only on windows.
Alan.
On Mon, May 10, 2010 at 11:05 PM, Ylian <ysainthilaire at hotmail.com> wrote:
> Hi.
>
> I own the Developer Tools for UPnP Technologies, I widely used set of tools
> for building and debugging UPnP related software. I have gotten many
> requests to run the tools on MONO and have gotten rid of all the C/C++
> native code and so far, it's working except for one problem:
>
> I need to bind to UDP port 1900 non-exclusively to receive SSDP multicast
> traffic. I use Ubuntu 10.04, MONO 2.4.4 and I get a "SocketException:
> Protocol Option not supported" when trying to set UdpClient's
> ExclusiveAddressUse property. Are there any alternatives?
>
> I am also trying to find precedents for UPnP work on MONO. My multicast
> socket setup code below (Apache 2.0 license).
>
> Thanks,
> Ylian
> opentools.homeip.net
>
> public class UPnPMulticastSniffer
> {
> public delegate void PacketHandler(object sender, string Packet, IPEndPoint
> Local, IPEndPoint From);
> public event PacketHandler OnPacket;
> private UdpClient client = null;
>
> public UPnPMulticastSniffer(IPEndPoint local)
> {
> client = new UdpClient(local.AddressFamily);
> client.ExclusiveAddressUse = false;
> client.Client.SetSocketOption(SocketOptionLevel.Socket,
> SocketOptionName.ExclusiveAddressUse, false);
> client.Client.SetSocketOption(SocketOptionLevel.Socket,
> SocketOptionName.ReuseAddress, true);
> client.EnableBroadcast = true;
> client.Client.Bind(local);
> if (local.AddressFamily == AddressFamily.InterNetwork)
> client.JoinMulticastGroup(IPAddress.Parse("239.255.255.250"),
> local.Address); if (local.AddressFamily == AddressFamily.InterNetworkV6)
> client.JoinMulticastGroup((int)local.Address.ScopeId,
> IPAddress.Parse("FF02::C")); client.BeginReceive(new
> AsyncCallback(OnReceiveSink), null);
> }
>
> public void OnReceiveSink(IAsyncResult ar)
> {
> IPEndPoint ep = null;
> byte[] buf = null;
> try { buf = client.EndReceive(ar, ref ep); } catch (Exception) { }
> if (buf != null && OnPacket != null) OnPacket(this,
> UTF8Encoding.UTF8.GetString(buf, 0,
> buf.Length), (IPEndPoint)client.Client.LocalEndPoint, ep); try {
> client.BeginReceive(new AsyncCallback(OnReceiveSink), null); } catch
> (Exception) { }
> }
>
> public void Dispose()
> {
> if (client == null) return;
> client.Close();
> client = null;
> }
> }
>
> ________________________________
> View this message in context: Porting UPnP Tools to MONO - Socket
> "ExclusiveAddressUse" problem
> Sent from the Mono - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
More information about the Mono-list
mailing list