squinnondation/for_testing_multicast/sender.py

16 lines
379 B
Python

from typing import Any, Tuple, Generator
from ipaddress import IPv6Address
import re
import socket
import time
import struct
# Initialise socket for IPv6 datagrams
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
sock.sendto("hello world".encode('utf-8'), ("ff02::4242:4242", 1212))