Add mutlicastjoin.py

master
informatic 2018-06-18 13:55:18 +02:00
parent 07ba937251
commit eda5b4de5e
2 changed files with 31 additions and 0 deletions

View File

@ -55,6 +55,13 @@ services:
volumes:
- ./api:/app
# FIXME this should be done in de-ip-hdmi...
multicast:
build: .
restart: unless-stopped
command: /tools/multicastjoin.py
network_mode: host
lenkeng1:
build: .
restart: unless-stopped

24
tools/multicastjoin.py Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/python
import socket, sys
from struct import *
import struct
import time
import sys
import logging
logging.basicConfig(level=logging.INFO)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 2068))
try:
mreq = struct.pack("=4sl", socket.inet_aton("226.2.2.2"), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
except:
logging.exception(':(')
sys.stderr.write('******* Subscribe failed')
time.sleep(30)