Skip to content

Can't create a UDP Socket and Multicast Socket #105

Closed
@Makuna

Description

@Makuna

I need to have two listening sockets (Contexts in Esp8266/Arduiino 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

    multicastSocket = new WiFiUDP();

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

unicast

    unicastSocket = new WiFiUDP();

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions