commit
c0fb239118
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/test" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.9 (ProjectCajero)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (ProjectCajero)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ProjectCajero.iml" filepath="$PROJECT_DIR$/.idea/ProjectCajero.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,22 @@
|
||||
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))
|
@ -0,0 +1,36 @@
|
||||
import socket
|
||||
|
||||
HOST = ''
|
||||
PORT = 2005
|
||||
MAX_CONNECTIONS = 2
|
||||
MAX_DINERO = 120000
|
||||
connections = 0
|
||||
#pip install six
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s_addr = (HOST, PORT)
|
||||
s.bind(s_addr)
|
||||
s.listen(MAX_CONNECTIONS)
|
||||
while True:
|
||||
if connections >= MAX_CONNECTIONS:
|
||||
print('Maximo de conexiones alcanzado, esperando a que se libere una conexion.')
|
||||
continue
|
||||
client_socket, addr = s.accept()
|
||||
connections += 1 # Increment connections after the check
|
||||
with client_socket:
|
||||
while True:
|
||||
datos = client_socket.recv(1024)
|
||||
if not datos:
|
||||
connections -= 1
|
||||
break
|
||||
print('Cliente connectetado y datos enviados : {} bytes de {}'.format(len(datos), addr))
|
||||
command, amount = datos.decode('utf-8').split()
|
||||
amount = int(amount)
|
||||
if command.lower() == 'retirar':
|
||||
print('retiro exitoso')
|
||||
if amount <= MAX_DINERO:
|
||||
MAX_DINERO -= amount
|
||||
response = f"Retiro Existoso."
|
||||
else:
|
||||
response = "Saldo insuficiente por favor intente mas tarde."
|
||||
client_socket.sendall(response.encode('utf-8'))
|
||||
print('enviados {} bytes de vuelta a {}'.format(len(response), addr))
|
Loading…
Reference in new issue