本文整理汇总了Python中Client.Client.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Client.connect方法的具体用法?Python Client.connect怎么用?Python Client.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.connect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getindex
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
def getindex(self):
try:
num = int(self._input('Peer Num : '))
peer = self.vpn.get_peer_by_num(num)
clt = Client(self.vpn)
print "[+] Connecting to %s at %s:%d ... [Ctrl+c]" % (peer[1], peer[2], peer[3])
clt.connect(peer[2], peer[3], (peer[4],peer[5]))
print "[+] Connected"
print "[+] Get Index ..."
clt.get_index(peer[0])
clt.close()
except Exception as e:
print "[Error]", e
except KeyboardInterrupt:
print "[!] Connection close"
else:
print "[+] Index downloaded"
示例2: downloadfile
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
def downloadfile(self):
try:
num = int(self._input('Peer Num : '))
peer = self.vpn.get_peer_by_num(num)
idfile = int(self._input('File ID : '))
name = Index(peer[0]).get_file_by_id(idfile)[1]
clt = Client(self.vpn)
print "[+] Connecting to %s at %s:%d ... [Ctrl+c]" % (peer[1], peer[2], peer[3])
clt.connect(peer[2], peer[3], (peer[4],peer[5]))
print "[+] Connected"
print '[+] Get File "%s" ...' % name
clt.get_file(idfile, name)
clt.close()
except Exception as e:
print "[Error]", e
except KeyboardInterrupt:
print "[!] Connection close"
else:
print "[+] File downloaded"
示例3: CreateVisitorCommand
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
class CreateVisitorCommand(CreateContextCommand):
def __init__(self, id, server, previous_operator = None, required_operator = None):
CreateContextCommand.__init__(self)
self.id = id
self.server = server
self.previous_operator = previous_operator
self.required_operator = required_operator
def process(self):
self.visitor = Client(self.server)
ok, error = self.visitor.connect()
return ok, self.visitor if ok else error
示例4: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
from Client import Client
clientA= Client()
clientA.connect()
while True:
user_input=input("Type message")
clientA.send_message(user_input)
print(clientA.recv_message())
示例5: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
from Client import Client
from sys import stdin
from Const import Const
client = Client(Const.SERVER_IP, Const.SERVER_PORT)
client.connect()
client.create_listen_thread()
print("Chat started: ")
while True:
msg = stdin.readline(Const.SERVER_PORT)
client.send_message(msg)
示例6: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
__author__ = 'Chema'
from Client.Client import *
y = Client("192.168.1.10",2525)
y.connect()
y.command()
示例7: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import connect [as 别名]
from Client import Client
clientB= Client()
clientB.connect()
while True:
user_input=input("Type message")
clientB.send_message(user_input)
print(clientB.recv_message())