client.py 618 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import socket
  2. from threading import Thread
  3. import threading
  4. SERVER = "10.8.0.6"
  5. PORT = 1488
  6. client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. client.connect((SERVER, PORT))
  8. client.sendall(bytes("979879789", "UTF-8"))
  9. def task():
  10. while True:
  11. in_data = client.recv(4096)
  12. print("От сервера :" ,in_data.decode())
  13. def task2():
  14. while True:
  15. out_data = input()
  16. client.sendall(bytes(out_data,'UTF-8'))
  17. print("Отпаравлено :" + str(out_data))
  18. t1 = Thread(target=task2)
  19. t2 = Thread(target=task)
  20. t1.start()
  21. t2.start()
  22. t1.join()
  23. t2.join()