im = pickle.dumps(archivo.read()) self.mensaje(IMAGEN+data[4:]+IMG_SEP+im) archivo.close() print "Image served: "+data[4:] def connectionMade(self): """Add to a list the clients connections. """ self.factory.clients.append(self) self.transport.write(WELCOME) def connectionLost(self,reason): """remove the connection from the list and send a message to other clients """ self.factory.clients.remove(self) def mensaje(self, datos): """send a message """ self.transport.write(datos) factory = Factory() factory.protocol = Packo factory.clients = [] factory.historico = [] factory.deshecho = [] reactor.listenTCP(8011, factory) reactor.run()