M
maehhheeyy
Hi, right now I'm using Python and Multicast. I have the code for
Multicast receiver on Python but I keep getting this error;
File "<string>", line 1, in bind
error: (10049, "Can't assign requested address")
The error is coming from this line;
sock.bind ((MCAST_ADDR, MCAST_PORT))
This is the code that I am using:
import socket
import time
ANY = "0.0.0.0"
SENDERPORT = 1501
MCAST_ADDR = "224.168.2.9"
MCAST_PORT = 1600
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)
status = sock.setsockopt(socket.IPPROTO_IP,
socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(MCAST_ADDR) +
socket.inet_aton(ANY));
sock.setblocking(0)
ts = time.time()
while 1:
try:
data, addr = sock.recvfrom(1024)
except socket.error, e:
pass
else:
print "We got data!"
print "FROM: ", addr
print "DATA: ", data
I'm using the UDP multicast. Is there anything that I did wrong in
this code?
Can anyone please help me solve this problem?
Multicast receiver on Python but I keep getting this error;
File "<string>", line 1, in bind
error: (10049, "Can't assign requested address")
The error is coming from this line;
sock.bind ((MCAST_ADDR, MCAST_PORT))
This is the code that I am using:
import socket
import time
ANY = "0.0.0.0"
SENDERPORT = 1501
MCAST_ADDR = "224.168.2.9"
MCAST_PORT = 1600
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 255)
status = sock.setsockopt(socket.IPPROTO_IP,
socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(MCAST_ADDR) +
socket.inet_aton(ANY));
sock.setblocking(0)
ts = time.time()
while 1:
try:
data, addr = sock.recvfrom(1024)
except socket.error, e:
pass
else:
print "We got data!"
print "FROM: ", addr
print "DATA: ", data
I'm using the UDP multicast. Is there anything that I did wrong in
this code?
Can anyone please help me solve this problem?