Peer-to-peer nós para processamento em multipontos
Publicado por Diego Lopes (última atualização em 31/05/2024)
[ Hits: 1.271 ]
Homepage:
Script simulam uma rede usando multipontos, o script pode ser alterado para rodar em quantos computadores forem desejados.
Esta conexão usa protocolo UDP.
#Author:Diego Silva #Date:04/23/2024 #Description:node to generate service and change information import socket from threading import Thread import time #setting info to server HOST='' PORT=4000 logged_node=False VERSION='1.0.0.0' nodehost='192.168.15.7' nodepor=4001 #thread process class ProcessNode(Thread): def __init__(self,udp,udp_client): Thread.__init__(self) self.udp = udp self.udp_client = udp_client def run(self): try: if logged_node==False: logged_node=True self.udp_c.sendto(b'hello',(nodehost,nodepor)) except: logged_node=False while 1: msg, client = self.udp.recvfrom(1024) print(msg) try: self.udp_client.sendto(msg,(nodehost,nodepor)) except: print("Node don't found") time.sleep(2) print("Done process") self.udp.close() #class up to server udp class UpServerSetting: def settingServerNode(self): msg="Error to up node, check setting port/host" try: print("Initing node server") server_udp = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) server_udp.bind((HOST,PORT)) msg="Node is Done" except: print("Fail to up node of net") finally: print(msg) return server_udp #class to clint another node class UpClientSetting: def settingClientNode(self): msg="Error To Generate Client" try: client_udp = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) msg="Done Object client udp" except: print(msg) finally: print(msg) return client_udp if __name__ == '__main__': print('Head Of Hydra {}'.format(VERSION)) sett = UpServerSetting() udp = sett.settingServerNode() sett_client = UpClientSetting() udp_c = sett_client.settingClientNode() udp_c.sendto(b'hello',(nodehost,nodepor)) while True: msg, client = udp.recvfrom(1024) if(msg.decode()=='hello'): print("Client loggin: ",msg.decode()) process = ProcessNode(udp,udp_c) process.start() print('Finishing client connection', client) udp.close() #process = ProcessNode(udp) #process.start()
Script para Scanner servidor e encontrar portas abertas
Aplicação gráfica para Wake-on-LAN com Python 3 + GUI Tk/Tcl
Atenção a quem posta conteúdo de dicas, scripts e tal (6)
O mínimo que você precisa saber sobre o terminal (parte 2)
O mínimo que você precisa saber sobre o terminal (parte 1)
Como iniciar uma máquina virtual do VirtualBox automaticamente no boot do LUbuntu 18 LTS
Os navegadores "leves" que de leves não tem nada
Liberte-se: Crie um Servidor Proxy na Nuvem para Acessar Conteúdos Bloqueados
Fedora Kinoite 40 — Instalação de drivers NVIDIA e Xorg
Deixando o Opensuse Tumbleweed com KDE bonitão
Estrutura de recuo PHP/Apache para não acessarem arquivos pela URI (barra de endereços)
Escanear a rede com NBTSCAN para descobrir IPs e nomes de computadores
Como instalar ou remover ambientes gráficos facilmente no openSUSE
Inicio de uso do Mint 32bits (1)
Icone da rede fica com sinal em zero porcento após conectado[DUV... (1)
como eu iinstalo o chromeos em uma cartão sd (21)
Criando partiçoes no HD com swap reservada de no máximo 1GB[AJUDA] (21)