Multiple OSCReceivers binding to a Single DatagramSocket, not working as expected

I’m trying to have different OSCReceive in different classes of my code listening to the same port. Connecting to the same port directly in the OSCReceivers with connect(int portNumber) in two different classes causes the second class to not be able to connect as expected.

So I took another approach by having a single DatagramSocket in my MainComponent and passing it to my classes to use in each of them the connectToSocket method, assuming this was the way to deal with this kind of problem.
But it seems only the first OSCReceiver to connect to the socket actually receives OSC. The second one seems to connect properly since there is no ConnectionErrorMessage, but the OSC never makes it to its listeners.
I don’t know what is happening under the hood but is the first OSCReceiver eating up the OSC messages and clearing something in the socket so that it never gets to the second one?

Here is my test code below if you want to recreate this.
It expects to receive the messages: /receiver1/a and /receiver2/a

MainComponent’s private variables:

DatagramSocket oscInSocket;
Receiver1 receiver1;
Receiver2 receiver2;    

in my MainComponent’s constructor:

if (! oscInSocket.bindToPort(51001) )
            showConnectionErrorMessage ("Error: could not create UDP socket");

receiver1.connectToUDPSocket(&oscInSocket);
receiver2.connectToUDPSocket(&oscInSocket);
receiver1.setupOSC();
receiver2.setupOSC();
        

note that switching the order changes which class receives the OSC:

if (! oscInSocket.bindToPort(51001) )
            showConnectionErrorMessage ("Error: could not create UDP socket");

receiver2.connectToUDPSocket(&oscInSocket);//order switched, receiver2 connecting first
receiver1.connectToUDPSocket(&oscInSocket);
receiver1.setupOSC();
receiver2.setupOSC();

And class definitions:

class BaseReceiver : public Component,
                    protected OSCReceiver,
                    protected OSCReceiver::ListenerWithOSCAddress<OSCReceiver::MessageLoopCallback>
{
public:
    BaseReceiver(){};
    
    void connectToUDPSocket(DatagramSocket * inputSocket)
    {
        if (! connectToSocket(*inputSocket))
            showConnectionErrorMessage ("Error: node could not connect to mainSocket");
    }
    void showConnectionErrorMessage (const String& messageText)
    {
        AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Connection error", messageText, "OK");
    }
    
    virtual void setupOSC() {};
    
private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BaseReceiver)

};


class Receiver1: public BaseReceiver
{
public:
    
    Receiver1(){};
    
    void setupOSC() override
    {
        addListener (this, "/receiver1/a");
    }
    
    void oscMessageReceived (const OSCMessage& message) override
    {
        if( message.getAddressPattern().toString() == "/receiver1/a") {
            printf("osc in a receiver1 editor\n");
            if (message.size() == 1 && message[0].isFloat32())
                printf("%f\n", message[0].getFloat32());
        }
    }
    
private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Receiver1)

};

class Receiver2: public BaseReceiver
{
public:
    Receiver2(){};
    
    void setupOSC() override
    {
        addListener (this, "/receiver2/a");
    }
    
    void oscMessageReceived (const OSCMessage& message) override
    {
        if( message.getAddressPattern().toString() == "/receiver2/a") {
            printf("osc in a receiver2 editor\n");
            if (message.size() == 1 && message[0].isFloat32())
                printf("%f\n", message[0].getFloat32());
        }
        
    }
    
private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Receiver2)
};

Did you already find out?
Ran into this during research…

If you head for that functionality you shoultn’d have the receiver and listener in a single class.
When you think this through, you’ll end up with what juce has ready for you:

there should be one receiver object (instance of a the OSCReceiver class) and two listener objects (instances of OSCReceiver::ListenerWithOSCAddress).
add these to the receiver (addListener()) with their address string and you have exactly the structure you were thinking of.

Greets