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.
22 lines
795 B
22 lines
795 B
7 months ago
|
import socket
|
||
|
|
||
|
HOST = '192.168.50.166'
|
||
|
PORT = 2005
|
||
|
|
||
|
while True:
|
||
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||
|
server_address = (HOST, PORT)
|
||
|
s.connect(server_address)
|
||
|
command = input("Entra comando (retirar o 'exit' para salir): ")
|
||
|
if command.lower() == 'exit':
|
||
|
break
|
||
|
elif command.lower() == 'retirar':
|
||
|
amount = input("Entera la cantidad de dinero: ")
|
||
|
message = f"{command} {amount}"
|
||
|
else:
|
||
|
print("Comando no reconocido")
|
||
|
print('Mandando {!r}'.format(message))
|
||
|
s.sendall(message.encode('utf-8'))
|
||
|
print('Esperando la respuesta')
|
||
|
data = s.recv(1024) # línea bloqueante
|
||
|
print('recibido {!r} de {}'.format(data.decode('utf-8'), server_address))
|