module:python:udpclientserver:udpclientserver
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
module:python:udpclientserver:udpclientserver [2021/12/11 21:03] – [UdpClientServer] omdevelop | module:python:udpclientserver:udpclientserver [2022/09/13 11:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
] | ] | ||
+ | PC-Udp-Kommunikation [[: | ||
[[: | [[: | ||
[[: | [[: | ||
- | |||
- | ----- | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
- | |||
- | |||
- | |||
- | ====== UdpClientServer - Bidirectional ====== | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
- | Bidirektionales Senden und Empfangen von UDP-Datenpaketen (OOP, Threading, NoBlocking) | ||
- | |||
- | ====== UdpClientServer - Unidirectional ====== | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
- | Unidirektionales Senden und Empfangen von UDP-Datenpaketen (NoBlocking) | ||
- | |||
- | |||
- | ===== Benutzung ===== | ||
- | * Datenaustausch zwischen UdpClient und UdpServer | ||
- | * UdpClient(Esp32) wartet (nicht blocking!) auf Daten vom UdpServer(Pc) | ||
- | * UdpClient(Pc) wartet (nicht blocking!) auf Daten vom UdpServer(Esp32) | ||
- | |||
- | SourceCode **PcUdpClient.py**, | ||
- | <code python> | ||
- | # | ||
- | import time | ||
- | import socket as SKT | ||
- | # | ||
- | UDP_IPADDRESS = ' | ||
- | UDP_IPPORT = 5005 | ||
- | # | ||
- | # | ||
- | if (' | ||
- | # | ||
- | print(' | ||
- | # | ||
- | Socket = SKT.socket(SKT.AF_INET, | ||
- | Socket.bind((UDP_IPADDRESS, | ||
- | Socket.setblocking(0) | ||
- | Loop = True | ||
- | while (Loop): | ||
- | try: | ||
- | Data, Address = Socket.recvfrom(1024) | ||
- | if (b' | ||
- | Loop = False | ||
- | except SKT.error: | ||
- | pass | ||
- | else: | ||
- | print(Data) | ||
- | finally: | ||
- | # debug print(' | ||
- | time.sleep(0.1) | ||
- | # | ||
- | Socket.close() | ||
- | # | ||
- | print(' | ||
- | # | ||
- | </ | ||
- | |||
- | SourceCode **PcUdpServer.py**, | ||
- | <code python> | ||
- | # | ||
- | import time | ||
- | import socket as SKT | ||
- | # | ||
- | UDP_IPADDRESS = ' | ||
- | UDP_IPPORT = 5005 | ||
- | # | ||
- | # | ||
- | if (' | ||
- | # | ||
- | print(' | ||
- | # | ||
- | Socket = SKT.socket(SKT.AF_INET, | ||
- | for I in range(0, 10): | ||
- | print(' | ||
- | Socket.sendto(b' | ||
- | time.sleep(1.0) | ||
- | # | ||
- | Socket.sendto(b' | ||
- | Socket.close() | ||
- | print(' | ||
- | # | ||
- | </ | ||
- | |||
- | {{: | ||
- | |||
- | |||
- | ===== Version ===== | ||
- | {{: | ||
- | {{: | ||
Line 132: | Line 23: | ||
[[http:// | [[http:// | ||
] | ] | ||
- | |||
module/python/udpclientserver/udpclientserver.1639253004.txt.gz · Last modified: 2021/12/11 22:03 (external edit)