You've already forked Curso-lenguaje-python
Update Python Ofensivo - Más ejercicios con conexiones socket
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
|
||||
|
||||
def start_client():
|
||||
|
||||
host = 'localhost'
|
||||
port = 1234
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect((host, port))
|
||||
|
||||
while True:
|
||||
msg = input("[+] Introduce un mensaje: ")
|
||||
|
||||
s.sendall(msg.encode('utf-8'))
|
||||
|
||||
if msg.strip() == 'bye':
|
||||
break
|
||||
|
||||
data = s.recv(1024)
|
||||
|
||||
print(f"\n[+] Mensaje del servidor: {data.decode().strip()}")
|
||||
|
||||
|
||||
start_client()
|
||||
Reference in New Issue
Block a user