alsmith / multicast-relay

Relay multicast and broadcast packets between interfaces.
GNU General Public License v3.0
304 stars 47 forks source link

ssdpDiscover errors under python3 #31

Closed aefo closed 4 years ago

aefo commented 4 years ago

Noticed that the help ssdpDiscover.py script doesn't seem to run correctly under python3. The changes below seemed to get it to work correctly. Thanks,

diff --git a/ssdpDiscover.py b/ssdpDiscover.py
index 4327c24..8d0ac57 100755
--- a/ssdpDiscover.py
+++ b/ssdpDiscover.py
@@ -25,16 +25,16 @@ def main():
         s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(args.ifAddr))

     s.settimeout(2)
-    s.sendto(msearch, ('239.255.255.250', 1900))
+    s.sendto(msearch.encode('utf-8'), ('239.255.255.250', 1900))

     try:
         while True:
             data, addr = s.recvfrom(65535)
             try:
-                print '%s [%s]' % (socket.gethostbyaddr(addr[0])[0], addr[0])
+                print ('%s [%s]' % (socket.gethostbyaddr(addr[0])[0], addr[0]))
             except socket.herror:
-                print addr[0]
-            print data
+                print (addr[0])
+            print (data)
alsmith commented 4 years ago

Thanks - committed in c00ed34