none
IP Multicast (UDP) on WES 7 RRS feed

  • Question

  • Dear fellow developers, any hints are appreciated, helping me with getting my simple multicast client application working on WES 7. It's written in C# and runs ok on a Windows 7 server (Windows Server 2008 SP 2), but when I try to run it on WES 7 I'm getting an error:

    System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
    at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
    at System.Net.Sockets.Socket.Bind(EndPoint localEP)
    at System.Net.Sockets.UdpClient..ctor(IPEndPoint localEP)

    Essentially I'm using the .NET framework's UdpClient class to join the multicast group.

    private string destinationAddress = "225.0.0.0";
    private int destinationPort = 7;
     // Create a multicast address
    ReceiveEndPoint = new IPEndPoint(IPAddress.Any, destinationPort);
    DestinationAddress = IPAddress.Parse(destinationAddress);
    MulticastClient = new UdpClient(ReceiveEndPoint);
    MulticastClient.JoinMulticastGroup(DestinationAddress);

    Later I use the MulticastClient to receive datagrams, but the application already fails at the statement where I create the MulticastClient for the given endpoint. I have tried different port numbers, and also made sure some TCP registry entries such as 'MaxUserPort' and 'TcpTimedWaitDelay' are present. But without any success. I'm new to WES, so maybe I'm missing something essential? Thanks - David

    Tuesday, May 17, 2011 1:53 PM

Answers

  • We have finally found the solution (i.e. not myself but someone in the Microsoft support network).

    It appears the port number has to be between 49152 and 65535.

     

    According to Microsoft ( http://support.microsoft.com/kb/929851/en-us):

    "To comply with Internet Assigned Numbers Authority (IANA) recommendations, Microsoft has increased the dynamic client port range for outgoing connections in Windows Vista and in Windows Server 2008. The new default start port is 49152, and the default end port is 65535. This is a change from the configuration of earlier versions of Windows that used a default port range of 1025 through 5000"

    While the article states that this has changed for Vista and Windows Server 2008, it has actually worked on my Windows Server 2008 machine, but not on WES7.

    • Marked as answer by David Maeder Wednesday, June 29, 2011 8:42 AM
    Monday, May 30, 2011 7:15 AM

All replies

  • Is the WES7 image a full OS image or a small custom built image? If small, try building a full iamge using the application Compatibility template.

     

    There is some settings in ICE that deal with TCP/IP and Multicast. Look in Windows Embedded Edition->TCPIP. The information is in the help, but here is the MSDN equivalent:

    http://msdn.microsoft.com/en-us/library/gg723591(v=WinEmbedded.1001).aspx

    -Sean

     


    www.sjjmicro.com / www.seanliming.com / www.annabooks.com, Book Author - ProGuide to WES 7, XP Embedded Advanced, WEPOS / POS for .NET Step-by-Step
    Tuesday, May 17, 2011 4:38 PM
    Moderator
  • Thanks Sean for your suggestion. We tried with the Application Compatibility Template, including all components, and we also tried that with other templates, but the problem persists.

    I'm thinking of changing my code, and use Socket class directly instead of UdpClient class, do you think that could make a difference?

    Thursday, May 19, 2011 2:13 PM
  • Program wise I cannot say if it will make a difference. This is a little out of my area at the moment.

    I puzzled on what the difference between Windows 7 adn WES7 full image that doesn't let the code run.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com / www.annabooks.com, Book Author - ProGuide to WES 7, XP Embedded Advanced, WEPOS / POS for .NET Step-by-Step
    Thursday, May 19, 2011 3:33 PM
    Moderator
  • Ok, here's some additional information which might be useful. I've changed my program slightly, instead of UdpClient class I'm working with the Socket class. Actually I'm doing exactly the same thing (as UdpClient class is only a convenience class using Socket class as well), but with Socket I have a finer granularity to see what's going on at socket level. So here's the exception, which now is a different one:

    System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.Bind(EndPoint localEP)

    So something with my access permission. Do I need to run the program under a special user account to work with sockets?

    Monday, May 23, 2011 3:24 PM
  • Is UAC enabled? If you run the application with ADministrative privaleges what happens?

    What are the firewall settings? Are accessing a closed port?

    -Sean


    www.sjjmicro.com / www.seanliming.com / www.annabooks.com, Book Author - ProGuide to WES 7, XP Embedded Advanced, WEPOS / POS for .NET Step-by-Step
    Monday, May 23, 2011 11:21 PM
    Moderator
  • We have finally found the solution (i.e. not myself but someone in the Microsoft support network).

    It appears the port number has to be between 49152 and 65535.

     

    According to Microsoft ( http://support.microsoft.com/kb/929851/en-us):

    "To comply with Internet Assigned Numbers Authority (IANA) recommendations, Microsoft has increased the dynamic client port range for outgoing connections in Windows Vista and in Windows Server 2008. The new default start port is 49152, and the default end port is 65535. This is a change from the configuration of earlier versions of Windows that used a default port range of 1025 through 5000"

    While the article states that this has changed for Vista and Windows Server 2008, it has actually worked on my Windows Server 2008 machine, but not on WES7.

    • Marked as answer by David Maeder Wednesday, June 29, 2011 8:42 AM
    Monday, May 30, 2011 7:15 AM