本文整理汇总了Python中Client.Client.recv方法的典型用法代码示例。如果您正苦于以下问题:Python Client.recv方法的具体用法?Python Client.recv怎么用?Python Client.recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.recv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import recv [as 别名]
def run(self) :
while True :
#采用select模型
#rs : 就绪读
#ws : 就绪写
#es : 就绪的错误信息
rs , ws ,es = select.select(self.inputs , [] ,[])
for r in rs :
if r is self.server:
conn , addr = self.server.accept()
print 'get conn from ' , addr
client = Client(conn , addr)
self.clientList[self.getIndex(addr)] = client
menuHandler = MenuHandler()
client.setHandler(menuHandler)
self.inputs.append(conn)
else :
try :
clientIndex = self.getIndex(r.getpeername())
client = self.clientList[clientIndex]
if not client:
print 'error , can not find the client :' ,clientIndex
data = r.recv(2048)
disconnected = False
if not data :
disconnected = True
else :
client.recv(data)
except Exception ,e:
print e
disconnected = True
if disconnected:
print r.getpeername() , 'disconnected'
client = self.clientList[self.getIndex(r.getpeername())]
client.disconnect()
del self.clientList[self.getIndex(r.getpeername())]
self.inputs.remove(r)
示例2: print
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import recv [as 别名]
print("")
p = input("Choose Option :")
p = int(p)
if p >= 6:
break
if p == 1:
username = input("Enter Username : ")
name = input("Enter Name : ")
email = input("Enter Email : ")
cedula = input("Enter Identity Card : ")
fecha = input("Enter Birth Date :")
imagen = input("Enter Profile pic Url : ")
usr = User(username, name, email, cedula, fecha, imagen)
s.send(usr.toString().encode('utf-8'))
enc = s.recv(1024)
res = enc.decode('utf-8')
if res == "YES":
s.send(usr.toString().encode('utf-8'))
print("User succsesfully added!!!\n")
else:
print("Error!!!!!!!!!")
elif p == 2:
username = input("Enter the Username to display : ")
username += "\n"+"ShowUser"
s.send(username.encode('utf-8'))
enc = s.recv(1024)
res = enc.decode('utf-8')
if res != " ":