Can't deliver multicast message

Status
Not open for further replies.

whyfaltu

Beta member
Messages
2
Hello All,
I am facing one strange problem related to multicasting. Please find the scenario of my problem as follows, it would be really great help if anybody can pin point my mistake:
I have a Windows 64-bit machine with 3 network interfaces, I created one multicasting group which has IP address:port as 225.100.100.100:6543 and added all 3 network interfaces into the multitasking group.
But when I send a UDP message to one of the interface on port 6543, the message is not delivered to the process but I can see with the help of wireshark tool that the message is reaching the machine on which above process is running.
I implemented program in C++ which doesn't work but the similar program in python does work. The sample code is:
#! /usr/bin/python

import socket
import struct
import sys

#Server part
if sys.argv[1] == 'server':
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 6543))
mreq = struct.pack('4sl', socket.inet_aton('225.100.100.100'), socket.INADDR_ANY)

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

while True:
print sock.recv(10240)
sock.close()

#client part
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 5)
sock.sendto(sys.argv[2], ('172.19.52.149', 6543))
sock.close()
 
I figured out the issue, I was having two processes waiting on multicast group 225.100.100.100, but I was sending the unicast message and only one of them used to receive it.

Is there a way to send unicast message to multiple processes waiting on same address and port?
 
Status
Not open for further replies.
Back
Top Bottom