Add TCP and UDP clients and servers

This commit is contained in:
2026-04-12 16:12:17 +03:00
parent 5938e80bc8
commit 820aa0e123
5 changed files with 49 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('127.0.0.1', 10000))
client.sendall(b'exit')
data = client.recv(1024)
print(f"Ответ от сервера: {data.decode()}")
client.close()
+7
View File
@@ -0,0 +1,7 @@
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.sendto(b'hello server', ('127.0.0.1', 20221))
data, _ = client.recvfrom(1024)
print(f"Ответ от сервера: {data.decode()}")
client.close()