Commit 66a19431 authored by Kirill Smelkov's avatar Kirill Smelkov

tmcast: Cosmetics

parent 4dc50bc8
...@@ -30,7 +30,7 @@ def _udpsockfor(ipaddr): # -> (sk, isipv6) ...@@ -30,7 +30,7 @@ def _udpsockfor(ipaddr): # -> (sk, isipv6)
return (sk, ip6) return (sk, ip6)
# mjoin_tx returns socket prepated to send/receive to/from multicast group:port. # mjoin_tx returns socket prepated to send to multicast group:port.
def mjoin_tx(group, port, ttl=100): def mjoin_tx(group, port, ttl=100):
sk, ip6 = _udpsockfor(group) sk, ip6 = _udpsockfor(group)
...@@ -50,13 +50,12 @@ def mjoin_tx(group, port, ttl=100): ...@@ -50,13 +50,12 @@ def mjoin_tx(group, port, ttl=100):
return sk return sk
# mjoin_rx returns socket prepated to send/receive to/from multicast group:port. # mjoin_rx returns socket prepated to receive from multicast group:port.
def mjoin_rx(group, port): def mjoin_rx(group, port):
sk, ip6 = _udpsockfor(group) sk, ip6 = _udpsockfor(group)
sk.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) sk.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sk.bind((group, port)) # works for reception even from multiple ifaces sk.bind((group, port)) # works for reception even from multiple ifaces
#sk.bind(('', port)) # XXX and later IP_MULTICAST_ALL=0 ?
# join the group on all interfaces # join the group on all interfaces
for ifidx, ifname in net.if_nameindex(): for ifidx, ifname in net.if_nameindex():
...@@ -70,7 +69,6 @@ def mjoin_rx(group, port): ...@@ -70,7 +69,6 @@ def mjoin_rx(group, port):
mreq = inet_pton(AF_INET, group) + \ mreq = inet_pton(AF_INET, group) + \
inet_pton(AF_INET, '0.0.0.0') + \ inet_pton(AF_INET, '0.0.0.0') + \
bifidx bifidx
#print(repr(mreq), len(mreq))
sk.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) sk.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
return sk return sk
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment