You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
365 B
16 lines
365 B
import socket
|
|
|
|
HOST, PORT = "localhost", 2000
|
|
data = "hola desde cliente tcp"
|
|
|
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
#conectar
|
|
sock.connect((HOST, PORT))
|
|
#enviar
|
|
sock.sendall(bytes(data + "\n", "utf-8"))
|
|
#recibir
|
|
recibido = str(sock.recv(64), "utf-8")
|
|
|
|
print("Enviado: {}".format(data))
|
|
print("Recibido: {}".format(recibido)) |