Here are the examples of the python api twisted.internet.reactor.connectTCP taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
87 Examples
3
View Complete Implementation : recipe-440555.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def start( self ):
try:
client = pb.PBClientFactory()
reactor.connectTCP('127.0.0.1', TorrentServer.torrentPort, client, 20)
dfr = client.getRootObject()
dfr.addCallbacks(self._gotRemote, self._didFail)
except: traceback.print_exc()
3
View Complete Implementation : recipe-466305.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def _start( self ):
print 'Waiting for Server...'
client = pb.PBClientFactory()
connector = reactor.connectTCP(host='127.0.0.1', port=PORT, factory=client, timeout=30)
dfr = client.getRootObject()
dfr.addCallbacks( self._gotRemote, self._remoteFail )
3
View Complete Implementation : recipe-502293.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def connectionMade(self):
self.serverName="%s:%d" %(self.factory.remote_host,self.factory.remote_port)
logger.info("client %s opened connection -> server %s" % (
self.clientName, self.serverName))
# cxn to this server has opened. Open a port to the destination...
reactor.connectTCP(self.factory.remote_host,
self.factory.remote_port, self.clientFactory)
3
View Complete Implementation : dict.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def define(host, port, database, word):
"""Look up a word using a dict server"""
d = defer.Deferred()
factory = DictLookupFactory("define", (database, word), d)
from twisted.internet import reactor
reactor.connectTCP(host, port, factory)
return d
3
View Complete Implementation : dict.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def match(host, port, database, strategy, word):
"""Match a word using a dict server"""
d = defer.Deferred()
factory = DictLookupFactory("match", (database, strategy, word), d)
from twisted.internet import reactor
reactor.connectTCP(host, port, factory)
return d
3
View Complete Implementation : portforward.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def connectionMade(self):
# Don't read anything from the connecting client until we have
# somewhere to send it to.
self.transport.pauseProducing()
client = self.clientProtocolFactory()
client.setServer(self)
from twisted.internet import reactor
reactor.connectTCP(self.factory.host, self.factory.port, client)
3
View Complete Implementation : test_pb.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def testLoginLogout(self):
factory = pb.PBClientFactory()
# NOTE: real code probably won't need anything where we have the
# "BRAINS!" argument, pasting None is fine. We just do it here to
# test that it is being pasted. It is used to give additional info to
# the realm to aid perspective creation, if you don't need that,
# ignore it.
d = factory.login(credentials.UsernamePastword("user", "past"),
"BRAINS!")
reactor.connectTCP("127.0.0.1", self.portno, factory)
d.addCallback(self._testLoginLogout_1, factory)
return d
3
View Complete Implementation : test_pb.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def _testBadLogin_once(self, res, username, pastword):
factory = pb.PBClientFactory()
creds = credentials.UsernamePastword(username, pastword)
d = factory.login(creds, "BRAINS!")
c = reactor.connectTCP("127.0.0.1", self.portno, factory)
d.addCallbacks(lambda res: self.fail("should have failed"),
lambda f: f.trap(UnauthorizedLogin))
d.addCallback(lambda res: factory.disconnect())
return d
3
View Complete Implementation : test_pb.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def testView(self):
factory = pb.PBClientFactory()
d = factory.login(credentials.UsernamePastword("user", "past"),
"BRAINS!")
reactor.connectTCP("127.0.0.1", self.portno, factory)
d.addCallback(lambda p: p.callRemote("getViewPoint"))
d.addCallback(lambda v: v.callRemote("check"))
d.addCallback(self.astertEquals, True)
d.addCallback(lambda res: factory.disconnect())
return d
3
View Complete Implementation : test_pb.py
Copyright MIT License
Author : adde88
Copyright MIT License
Author : adde88
def testNSP(self):
factory = pb.PBClientFactory()
d = factory.login(credentials.UsernamePastword('user', 'past'),
"BRAINS!")
reactor.connectTCP('127.0.0.1', self.portno, factory)
d.addCallback(lambda p: p.callRemote('ANYTHING', 'here', bar='baz'))
d.addCallback(self.astertEquals,
('ANYTHING', ('here',), {'bar': 'baz'}))
d.addCallback(lambda res: factory.disconnect())
return d