How to use the twisted.internet.reactor.listenTCP function in Twisted

To help you get started, we’ve selected a few Twisted examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ClusterHQ / powerstrip / powerstrip / testtools.py View on Github external
self.socketPath = realDockerSocket

        self.config = PluginConfiguration()
        tmp = self.mktemp()
        self.config._default_file = tmp
        fp = FilePath(tmp)
        fp.setContent(config_yml)
        self.parser = EndpointParser(self.config)
        if dockerOnSocket:
            self.proxyAPI = powerstrip.ServerProtocolFactory(
                    dockerSocket=self.socketPath, config=self.config)
        else:
            self.proxyAPI = powerstrip.ServerProtocolFactory(
                                dockerAddr="127.0.0.1", dockerPort=self.dockerPort,
                                config=self.config)
        self.proxyServer = reactor.listenTCP(powerstripPort, self.proxyAPI)
        self.proxyPort = self.proxyServer.getHost().port
github SpriteLink / NIPAP / nipap / nipap / xmlrpc.py View on Github external
reactor.listenTCP(self._cfg.getint('nipapd', 'port'), server.Site(self._protocol))
        else:
            # If the used has listed specific addresses to listen to, loop
            # through them and start listening to them. It is possible to
            # specify port per IP by separating the address and port with a +
            # character.
            listen = self._cfg.get('nipapd', 'listen')
            for entry in listen.split(','):
                if len(entry.split('+')) > 1:
                    address = entry.split('+')[0]
                    port = int(entry.split('+')[1])
                else:
                    address = entry
                    port = int(self._cfg.get('nipapd', 'port'))
                self.logger.info("Listening to address " + address + " on port " + str(port))
                reactor.listenTCP(port, server.Site(self._protocol), interface=address)

        # finally, start the reactor!
        reactor.run()
github smartbgp / yabmp / yabmp / service.py View on Github external
try:
        CONF(args=args, project='yabmp', version=version,
             default_config_files=['/etc/yabmp/yabmp.ini'])
    except cfg.ConfigFilesNotFoundError:
        CONF(args=args, project='yabmp', version=version)

    log.init_log()
    LOG.info('Log (Re)opened.')
    LOG.info("Configuration:")

    cfg.CONF.log_opt_values(LOG, logging.INFO)

    handler.init()
    # start bmp server
    try:
        reactor.listenTCP(
            CONF.bind_port,
            BMPFactory(handler=handler),
            interface=CONF.bind_host)
        LOG.info(
            "Starting bmpd server listen to port = %s and ip = %s",
            CONF.bind_port, CONF.bind_host)
        reactor.run()
    except Exception as e:
        LOG.error(e)
github D3f0 / txscada / src / restscada / rest / publisher.py View on Github external
def main(argv = sys.argv):
    from twisted.internet import reactor
    
    class MyRoot(RestResourcePublisher):
        ''' Definimos un recurso de prueba'''
        pass
    puerto = 8003
    m = MyRoot()
    sa_entity = "En progreso"
    m.register(sa_entity)
    root = MyRoot()
    site = server.Site(root)
    reactor.listenTCP(puerto, site) #@UndefinedVariable
    print "Correindo en locahost:%d" % puerto
    reactor.run() #@UndefinedVariable
    
    return
github SoftwareQuTech / SimulaQron / run / log / startCQCLog.py View on Github external
def setup_CQC_server(name, cqc_factory):
    """Setup CQC server to handle remote on the classical communication network."""
    try:
        logging.debug(
            "LOCAL %s: Starting local classical communication server.", name
        )
        myHost = cqc_factory.host
        myHost.root = cqc_factory
        myHost.factory = cqc_factory
        reactor.listenTCP(myHost.port, myHost.factory)
    except CannotListenError as e:
        logging.error(
            "LOCAL {}: CQC server address ({}) is already in use.".format(
                name, myHost.port
            )
        )
        reactor.stop()
    except Exception as e:
        logging.error(
            "LOCAL {}: Critical error when starting CQC server: {}".format(name, e)
        )
        reactor.stop()
github twisted / twisted / doc / core / howto / listings / process / quotes.py View on Github external
def connectionMade(self):
        output = utils.getProcessOutput(self.fortune)
        output.addCallbacks(self.writeResponse, self.noResponse)

    def writeResponse(self, resp):
        self.transport.write(resp)
        self.transport.loseConnection()

    def noResponse(self, err):
        self.transport.loseConnection()


if __name__ == '__main__':
    f = protocol.Factory()
    f.protocol = FortuneQuoter
    reactor.listenTCP(10999, f)
    reactor.run()
github ibid / ibid / ibid / source / telnet.py View on Github external
def setServiceParent(self, service=None):
        if service:
            self.listener = internet.TCPServer(self.port, self).setServiceParent(service)
            return self.listener
        else:
            self.listener = reactor.listenTCP(self.port, self)
github scalingexcellence / scrapybook / resources / web / app / web.py View on Github external
def getChild(self, name, request):
        return self

    def render_GET(self, request):
        return ('Resource not found. Try: '
                '<a href="properties/index_00000.html">properties</a> '
                '<a href="images">images</a>, '
                '<a href="dynamic">dynamic</a>, '
                '<a href="benchmark">benchmark</a> ')

if __name__ == '__main__':

    site = server.Site(Root())

    reactor.listenTCP(9312, site)

    reactor.run()
github torque59 / nosqlpot / redispot / redisdeploy.py View on Github external
def reddeploy(port=6109,method='stdout'):
    if method != 'stdout':
	log.startLogging(open('redis.log', 'a'))  
    else:
	log.startLogging(sys.stdout)
    reactor.listenTCP(port, RedisServerFactory())
    reactor.run()
github methane / echoserver / server_twisted.py View on Github external
def main():
    f = Factory()
    f.protocol = Echo
    reactor.listenTCP(5000, f, backlog=1024)
    reactor.run()