Atualizar
This commit is contained in:
parent
63b89b59ae
commit
a33ad6b6c9
|
|
@ -1,5 +1,6 @@
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
servidor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
servidor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
servidor.bind(("0.0.0.0",5000))
|
servidor.bind(("0.0.0.0",5000))
|
||||||
|
|
@ -9,15 +10,19 @@ print("Servidor inicializado!!!")
|
||||||
clientes = []
|
clientes = []
|
||||||
|
|
||||||
def ouvir_cliente(cliente):
|
def ouvir_cliente(cliente):
|
||||||
|
funcionar = True
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
mensagem = cliente.recv(1024)
|
if funcionar:
|
||||||
|
mensagem = cliente.recv(8000)
|
||||||
for socket_cliente in clientes:
|
for socket_cliente in clientes:
|
||||||
if socket_cliente != cliente:
|
if socket_cliente != cliente:
|
||||||
socket_cliente.send(mensagem)
|
socket_cliente.send(mensagem)
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Ocorreu um erro inesperado: {e}")
|
print(f"Ocorreu um erro inesperado: {e}")
|
||||||
return
|
funcionar = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
cliente, endereco_cliente = servidor.accept()
|
cliente, endereco_cliente = servidor.accept()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue