-->
Page 1 of 1

Can't create a UDP Socket and Multicast Socket

PostPosted: Fri Apr 24, 2015 6:34 pm
by Makuna
I need to have two listening sockets (Contexts in Esp8266/Arduino speak) for my CoapServer. One for the Multicast and one for a unicast. They both use the same port by CoAp standards.

Which ever one is created first succeeds, but the second one created fails in UdpContext::Listen. The call to udp_bind within UdpContext::Listen returns error code is ERR_USE; meaning the address is in use?

Coap Port is 5684
Coap Multicast Address is 224.0.1.187

By normal socket concepts this should be doable, not so sure by Esp8266 context concepts.

Further, if I just create a multicast socket, while it will receive multicast packets, it will not receive packets sent directly to the ipaddress of the device. This works as I would expect IF I can create the two functional sockets.

here are snippits of the code, just for completeness, they work independently but not when called back to back.

multicast
Code: Select all        multicastSocket = new WiFiUDP();

        if (!multicastSocket ->beginMulticast(WiFi.localIP(),
            IPAddress(CoapMultiCastAddress) ,
            CoapPort))
        {
            // error
        }

unicast
Code: Select all    unicastSocket = new WiFiUDP();

    // unicast
    if (!unicastSocket->begin(CoapPort))
    {
        // error
    }

Re: Can't create a UDP Socket and Multicast Socket

PostPosted: Mon May 04, 2015 11:34 am
by Makuna
Just an update. These calls are exclusive, you do one or the other. A new method was added since I originally posted this that allows for the multicast connection to provide the "target" ip of the received packet so you can tell if it was sent by unicast or multicast.

Now my problem is that either of these only accepts about 8 packets before ceasing receiving any more packets.

Re: Can't create a UDP Socket and Multicast Socket

PostPosted: Thu May 07, 2015 5:46 pm
by Makuna
Makuna wrote:Now my problem is that either of these only accepts about 8 packets before ceasing receiving any more packets.


Well, this turned out to be a problem with a Wifi router. I have two, a primary house hold and a IoT. For some reason still unknown to me the IoT router (different make and model) is causing the problem, either through some strange interaction with the esp8266 or just plain is broken.

Re: Can't create a UDP Socket and Multicast Socket

PostPosted: Thu May 11, 2017 5:05 am
by kevstev01
Not sure what you meant, and I need to implement Multicast and Unicast UDP communication. Did you implement Multicast and use the new call to inspect the sending address to filter Multicast as Unicast messages:?:
Thanks for your help!