Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
471 B
1
Indexable
Never
import socket

host = socket.gethostname()
print(host)
port = 8080

client_socket = socket.socket()
print("Conectando ao servidor...")
client_socket.connect((host, port))
print("Conectado ao servidor.")
message = input(" -> ")

while message.lower().strip() != 'tchau':
    client_socket.send(message.encode())
    data = client_socket.recv(1024).decode()

    print('Recebida do servidor: ' + data)

    message = input(" -> ")

client_socket.close()
Leave a Comment