本文整理汇总了Python中socket.socket.sendall函数的典型用法代码示例。如果您正苦于以下问题:Python sendall函数的具体用法?Python sendall怎么用?Python sendall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendall函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: sendPack
def sendPack(socket, tag = "", data = ""):
# Determine packet length.
packetLength = 2 + TAG_LEN + len(data)
# Build packet.
packet = pack(">H", packetLength)
packet += tag.ljust(TAG_LEN, "\0")
packet += data
# Send packet to the server.
try:
socket.sendall(packet)
except Exception as e:
print e.strerror
sys.exit(1)
开发者ID:wilsonsk,项目名称:cs372,代码行数:15,代码来源:ftclient.py
示例3: sendPacket
def sendPacket(socket, handle, message):
# Determine message packet length.
packetLength = 2 + HANDLE_SIZE + len(message)
# Build the message packet.
packet = pack('>H', packetLength)
packet += handle.ljust(HANDLE_SIZE, '\0')
packet += message
# Send message packet to the server.
try:
socket.sendall(packet)
except Exception as e:
print e.strerror
sys.exit(1)
开发者ID:TatyanaV,项目名称:Introduction-to-C-part-1,代码行数:15,代码来源:chatclient1.py
示例4: ssl_sendall
def ssl_sendall(self, data, flags=0):
self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
amount = len(data)
done = count = 0
start = time.time()
io = BytesIO(data)
while True:
count += 1
# calc current rate
now = time.time()
elapsed = now - start
rate = float(done) / elapsed
if rate > RATE:
time.sleep(0.5)
continue
chunk = io.read(CHUNK_SIZE)
if chunk:
self.send(chunk)
done += len(chunk)
if count % 15 == 0:
stats.record_fileprogress(done, amount)
else:
break
return amount
else:
return socket.sendall(self, data, flags)
开发者ID:vangheem,项目名称:clouddrive,代码行数:35,代码来源:patches.py
示例5: makeRequest
def makeRequest(socket, tag = "", data = ""):
# calculate the packet length, data + tag(8 bytes) + length bytes(2 bytes)
packetLength = 2 + 8 + len(data)
# construct the packet
# sources: https://docs.python.org/2/library/struct.html
# http://www.tutorialspoint.com/python/string_ljust.htm
packet = pack(">H", packetLength)
packet += tag.ljust(8, "\0")
packet += data
# send packet to server
# https://docs.python.org/2/tutorial/errors.html
try:
socket.sendall(packet)
except Exception as e:
print e.strerror
sys.exit(1)
开发者ID:kara-franco,项目名称:simple-file-transfer-program,代码行数:18,代码来源:ftclient.py
示例6: sendall
def sendall(self, data, flags=0):
self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError('non-zero flags not allowed in calls to sendall() on %s' % self.__class__)
amount = len(data)
count = 0
while count < amount:
v = self.send(data[count:])
count += v
return amount
return socket.sendall(self, data, flags)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:12,代码来源:ssl.py
示例7: sendall
def sendall(self, data, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
amount = len(data)
count = 0
while (count < amount):
v = self.send(data[count:])
count += v
return amount
else:
return socket.sendall(self, data, flags)
开发者ID:KrishMunot,项目名称:pyston,代码行数:14,代码来源:ssl.py
示例8: sendall
def sendall(self, data, flags=0):
self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
count = 0
with memoryview(data) as view, view.cast("B") as byte_view:
amount = len(byte_view)
while count < amount:
v = self.send(byte_view[count:])
count += v
else:
return socket.sendall(self, data, flags)
开发者ID:1st1,项目名称:cpython,代码行数:15,代码来源:ssl.py
示例9: sendall
def sendall(self, data, flags = 0, raw = False):
amount = len(data)
count = 0
while count < amount:
v = self.send(data[count:], flags, raw)
count += v
return count
if not raw:
amount = len(data)
count = 0
while count < amount:
v = self.send(data[count:], flags)
count += v
return count
else:
return socket.sendall(self, data, flags)
开发者ID:lsowen,项目名称:pySchannelSSL,代码行数:17,代码来源:sslsocket.py
示例10: sendall
def sendall(self, data, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
print "LEN DATA"
amount = len(data)
print amount
print "LEN DATA"
if isinstance(data, str):
count = 0
while (count < amount):
v = self.send(data[count:])
count += v
else:
self.send(data)
return amount
else:
return socket.sendall(self, data, flags)
开发者ID:bdeluca,项目名称:python-api,代码行数:21,代码来源:ssl.py
示例11: sendall
def sendall(self, *args, **kwargs):
time.sleep(random.random() * seconds)
return _socket.sendall(self, *args, **kwargs)
开发者ID:bossjones,项目名称:mrq,代码行数:3,代码来源:monkey.py
注:本文中的socket.socket.sendall函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论