Hi I'm having some kind of problem here that I can't identify ...

I want to get UDP data that is sent to a multicast address so my guess is to create a socket and bind it to the multicast address and port where the data is sent to . I'm using openSUSE and coding in c++

I configure the socket

Code:
    struct sockaddr_in mysocket;
    struct ip_mreq group;
    int sd;
    int dblength;
    char dbuffer[1024];
    int reuse = 1;

try{
	sd = socket(AF_INET, SOCK_DGRAM, 0);
        setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse));
           
        memset((char *) &mysocket, 0, sizeof(mysocket));
        misocket.sin_family = AF_INET;
        misocket.sin_port = htons((unsigned int)multicastport.c_str());
        misocket.sin_addr.s_addr = htonl(INADDR_ANY); 
    
    bind(sd, (struct sockaddr*)&misocket, sizeof(misocket));
          
    group.imr_multiaddr.s_addr = inet_addr(multicastaddress.c_str());
    group.imr_interface.s_addr = inet_addr("192.168.0.8");
                setsockopt(sd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&group, sizeof(group));
          }
And here I try to read from the socket :

Code:
int readLength = -1;
        printf("\nReading from socket");

        try{
        while((readLength=read(sd, dbuffer, dblength)) >=0){
            //some data processing here when it works
            cout << readLength <<endl;
            printf(dbuffer);
        }
        if(readLength < 0){
            printf("\nError buffer empty\n");
        }

        close (sd);
        printf("\nReading .... OK\n");}
        catch(unsigned int a){
            perror("Error reading");
            close(sd);
        }
I get this output

Code:
Reading from socket
Error buffer empty
Reading .... OK
It compiles and executes "ok" and I know for sure (wireshark captures and server's log) that the UDP packets are being sent so I don't know why I'm not receiving... socket not correctly configurated?

Any idea where am I failing?

JessH