feat: add TCP and UDP client-server scripts
This commit is contained in:
1 parent
a56496622d
commit
48b3cca2c4
4 files changed
+56
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import socket
|
||||
|
||||
def send_tcp(message: bytes):
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect(('127.0.0.1', 10000))
|
||||
client.sendall(message)
|
||||
data = client.recv(1024)
|
||||
print(f"Отправлено: {message.decode()} | Ответ от сервера: {data.decode()}")
|
||||
client.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
send_tcp(b'hello server')
|
||||
send_tcp(b'exit')
|
||||
Reference in new issue
Block a user