module:python:pcudpclientserver:pcudpclientserver
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
module:python:pcudpclientserver:pcudpclientserver [2021/12/11 20:53] – [UdpClientServer] omdevelop | module:python:pcudpclientserver:pcudpclientserver [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== UdpClientServer ====== | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
- | |||
- | [[ |Bidirektionales Senden und Empfangen von UDP-Datenpaketen (OOP, Threading, NoBlocking)]] | ||
- | |||
- | [[ |Unidirektionales Senden und Empfangen von UDP-Datenpaketen (NoBlocking)]] | ||
- | |||
- | |||
- | ====== UdpClientServer - Unidirectional ====== | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
- | Bidirektionales Senden und Empfangen von UDP-Datenpaketen (OOP, Threading, 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 ===== | ||
- | {{: | ||
- | {{: | ||
- | |||
- | |||
- | ----- | ||
- | [[http:// | ||
- | [ | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | [[http:// | ||
- | ] | ||
- | |||
module/python/pcudpclientserver/pcudpclientserver.1639252409.txt.gz · Last modified: 2021/12/11 21:53 (external edit)