I am trying to write a listener , which will listen to multicast data from different systems. As per my understanding, any system which is present in the same subnet will be able to get any data that will be sent to a particular muticast_grp and multicast port. But in my case, the below code is working fine for any data which will be sent to the same PC, but is NOT able to capture the data which will be sent from another PC.
I am able to see the data in Wireshark. But not in the reciver. I don't have control over the server(sender)
import socket
import struct
import sys
MCAST_GRP = '239.255.255.250'
MCAST_PORT = 3702
IS_ALL_GROUPS = True
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', MCAST_PORT))
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
while True:
print(sock.recv(10240))