本文整理汇总了Python中socket.socket.recv函数的典型用法代码示例。如果您正苦于以下问题:Python recv函数的具体用法?Python recv怎么用?Python recv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recv函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,db):
self._ipcPath=db.getSettingPath()
SocketlikeIPC.__init__(self, self._ipcPath)
# super(type(self),self).__init__(self._ipcPath)
# if super(type(self),self)._connect():
if SocketlikeIPC._connect(self):
print('IPC connect succeed. Welcome back, administrator.')
return
print('IPC failed. proceeding with TCP.')
super(type(self)) #unbound
socket.__init__(self)
try:
socket.connect(self,('racu.idea.sh', PortEnum.MAIN_SERVER.value))
lastPin = db.getConfig()
print('lastPin =', lastPin, len(lastPin))
pinmsg = int.to_bytes(SocketEnum.PIN.value, 1, 'big') + int.to_bytes(lastPin[0]) if 10**3<=lastPin['lastPIN']<10**4 else b''
msg = ''
# while not msg:
socket.sendall(self,pinmsg)
msg = socket.recv(self)
if not msg:
print('main server connect error')
return
except:
print('main server connect error')
开发者ID:chidea,项目名称:rebauth,代码行数:25,代码来源:ServerSocket.py
示例2: recv
def recv(self, buflen=1024, flags=0):
self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError('non-zero flags not allowed in calls to recv() on %s' % self.__class__)
return self.read(buflen)
return socket.recv(self, buflen, flags)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:ssl.py
示例3: recv
def recv(self, buflen=1024, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError("non-zero flags not allowed in calls to recv() on %s" % self.__class__)
return self.read(buflen)
else:
return socket.recv(self, buflen, flags)
开发者ID:Jaykul,项目名称:ChocolateyPackages,代码行数:7,代码来源:ssl.py
示例4: recv
def recv(self, buffersize, flags = 0, raw = False):
if not raw:
data = self._sslobj.recv(buffersize, flags)
#print("RECV: {0}".format(data))
return data
else:
data = socket.recv(self, buffersize, flags)
#print("RECV (raw): {0}".format(data))
return data
开发者ID:lsowen,项目名称:pySchannelSSL,代码行数:9,代码来源:sslsocket.py
示例5: getRequest
def getRequest (socket) :
"""
receive bytes from a socket
socket the socket of the client
return a string containing the client's request
"""
request = socket.recv(MAX_FILE_SIZE)
request = bytes.decode(request)
print(request)
return request
开发者ID:zjg95,项目名称:cs356-routing-table,代码行数:10,代码来源:server-zjg95.py
示例6: recvFile
def recvFile(socket, numBytes):
# Retrieve the given number of bytes.
data = "";
while len(data) < numBytes:
try:
data += socket.recv(numBytes - len(data))
except Exception as e:
print e.strerror
sys.exit(1);
return data
开发者ID:wilsonsk,项目名称:cs372,代码行数:11,代码来源:ftclient.py
示例7: send
def send(self, topic, msg):
if type(topic) != bytes:
topic = bytes(str(topic), 'utf-8')
messagedata = bytes(json.dumps(msg), 'utf-8')
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect(self._relay_in)
socket.send(topic + b' ' + messagedata)
reply = socket.recv()
assert reply
开发者ID:oksome,项目名称:Intercom,代码行数:11,代码来源:minion.py
示例8: receiveData
def receiveData(socket, bytesNumber):
# data will collect the number of bytes
# will be called a number of times
# source: http://stackoverflow.com/questions/7174927/when-does-socket-recvrecv-size-return
data = "";
while len(data) < bytesNumber:
try:
data += socket.recv(bytesNumber - len(data))
except Exception as e:
print e.strerror
sys.exit(1);
return data
开发者ID:kara-franco,项目名称:simple-file-transfer-program,代码行数:13,代码来源:ftclient.py
示例9: readClientMessage
def readClientMessage(self, socket):
data = socket.recv(1024)
if not data:
socket.close()
self.sockets.remove(socket)
return None
else:
print '\tRead:', data, 'on', id(socket)
tokens = string.split(data)
return tokens
开发者ID:SeanCCarter,项目名称:ohell,代码行数:13,代码来源:server.py
示例10: recv
def recv (self, buflen=1024, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
while True:
try:
return self.read(buflen)
except SSLError, x:
if x.args[0] == SSL_ERROR_WANT_READ:
continue
else:
raise x
else:
return socket.recv(self, buflen, flags)
def recv_into (self, buffer, nbytes=None, flags=0):
if buffer and (nbytes is None):
nbytes = len(buffer)
elif nbytes is None:
nbytes = 1024
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to recv_into() on %s" %
self.__class__)
while True:
try:
tmp_buffer = self.read(nbytes)
v = len(tmp_buffer)
开发者ID:AkshayJoshi,项目名称:python,代码行数:31,代码来源:ssl.py
示例11: recv
def recv(self, *args, **kwargs):
time.sleep(random.random() * seconds)
return _socket.recv(self, *args, **kwargs)
开发者ID:bossjones,项目名称:mrq,代码行数:3,代码来源:monkey.py
示例12: socket
lContact = [c1, c2]
ss = socket(AF_INET, SOCK_STREAM)
ss.bind(('192.168.28.83', 4269))
ss.listen(5)
print("Serveur lancé en écoute")
msg = "\n 1 = findNom \n 2 = findTel \n 3 = addByNomTel \n 4 = deleteByNom"
print(msg)
socket, info = ss.accept()
while (True):
commande = socket.recv(16)
commande = commande.decode()
print(commande)
socket.send((sys.argv[1] + "\rtoast\n").encode())
if commande == "1":
nom = socket.recv(512)
nom = nom.decode()
c = findContactByNom(lContact, nom)
socket.sendto(c)
if commande == "2":
nom = socket.recv(512)
nom = nom.decode()
开发者ID:CamTosh,项目名称:Cours-Python,代码行数:30,代码来源:__init__.py
注:本文中的socket.socket.recv函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论