Advertisement
piffy

TCP Client (Python)

Aug 10th, 2022
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import socket
  2.  
  3. #Con il costrutto with il socket si chiude automaticamente.
  4. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  5.     s.connect(('locahlhost', 6666))
  6.     messaggio=input('-> ')
  7.     s.sendall(messaggio.encode())
  8.     data = s.recv(len(messaggio))
  9.  
  10. print(f"Ricevuto {data.decode()}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement