본문 바로가기
socket

python - multicast send with esp8266

by space father python 2023. 1. 2.
반응형

https://arduino-dds.tistory.com/entry/esp8266-multicast-with-python-pc

 

esp8266 - multicast with python pc

https://python-dds.tistory.com/entry/python-multicast-receive-with-esp8266 https://python-dds.tistory.com/entry/python-multicast-send-with-esp8266 python - multicast send with esp8266 Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import socket MCAST_GRP = '224.

arduino-dds.tistory.com

Code

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import socket
 
MCAST_GRP = '224.1.1.1'
MCAST_PORT = 5123
MULTICAST_TTL = 2
 
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MULTICAST_TTL)
 
send_str = f'python_({MCAST_PORT})\n'
sock.sendto(send_str.encode(), (MCAST_GRP, MCAST_PORT))
print(f'send_msg:{send_str}')
sock.sendto(bytes(send_str, "utf-8"), (MCAST_GRP, MCAST_PORT))
print(f'send_msg:{send_str}')
 
cs

 

 

Result

$ python3 multicast_sendto_test.py 

send_msg:python_(5123)

send_msg:python_(5123)

'socket' 카테고리의 다른 글

Python - UDP (send, receive)  (0) 2023.01.05
Python - all ip check in pc  (0) 2023.01.04
python - multicast receive with esp8266  (0) 2023.01.02