dcalvo
Posts: 4
Joined: Sat Jan 06, 2018 12:14 am

Multicast (SSDP) script in Python working in Windows but not in Raspberry

Sat Jan 06, 2018 12:19 am

Hello all,

I'm trying to create a little program to listen to SSDP messages (they use multicast) in my local network. While the code works in WIndows 10 and shows me any multicast to the specified address, whenever I try to use it in my raspberry Pi 3, it shows nothing. I've been doing so many modifications trying to find the key but so far, no success.

The program runs, but there is no message coming from it. The code is the same in both platforms (well, IP addresses are different, ;-) )

Can someone help me to find out where the problem might be as it's driving me crazy or helping me out with some tips? Thank you.

Code: Select all

import socket
import struct
import http.client

class ssdp(object):
    def __init__(self, grupo=("239.255.255.250", 1900)):
        self.group = grupo
        self.numItems = 0
        self.responses = []
        return

    def listen(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        sock.bind(('', self.group[1]))
        mreq = struct.pack('4s4s', socket.inet_aton(self.group[0]), socket.inet_aton('192.168.1.42'))

        sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

        while True:
            print(sock.recv(1024))
        return

respuesta = ssdp()

respuesta.listen()

boonie1123
Posts: 1
Joined: Wed Jul 05, 2017 3:19 pm

Re: Multicast (SSDP) script in Python working in Windows but not in Raspberry

Wed Feb 21, 2018 10:17 am

I get the same Issue, I have a device discoverer that uses messages over the broadcast IP and it works on windows. As soon as I run it on my Pi it just doesn't send anything. I don't get any errors which is weird.

Return to “Python”