本文整理汇总了Python中socket.sendall方法的典型用法代码示例。如果您正苦于以下问题:Python socket.sendall方法的具体用法?Python socket.sendall怎么用?Python socket.sendall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块socket的用法示例。
在下文中一共展示了socket.sendall方法的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: sendAPRSPacket
点赞 6
# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def sendAPRSPacket(socket, packet):
"""
Sends an APRS packet (just a string) to the socket specified. If an
error occurs a False is returned while a True is returned if successful.
On an error, the socket is closed as it is no longer useful.
:param socket: APRS-IS server internet socket
:param packet: String to be sent to APRS-IS
:return: Boolean
"""
try:
socket.sendall(packet)
return True
except IOError as e:
logger.error(e)
socket.close()
return False
开发者ID:FaradayRF,项目名称:Faraday-Software,代码行数:21,
示例2: escape
点赞 6
# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def escape(self, data):
"""\
This generator function is for the user. All outgoing data has to be
properly escaped, so that no IAC character in the data stream messes up
the Telnet state machine in the server.
socket.sendall(escape(data))
"""
for byte in iterbytes(data):
if byte == IAC:
yield IAC
yield IAC
else:
yield byte
# - incoming data filter
开发者ID:cedricp,项目名称:ddt4all,代码行数:18,
示例3: write
点赞 6
# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def write(self, data):
"""\
Output the given string over the serial port. Can block if the
connection is blocked. May raise SerialException if the connection is
closed.
"""
if not self._isOpen: raise portNotOpenError
self._write_lock.acquire()
try:
try:
self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
except socket.error, e:
raise SerialException("connection failed (socket error): %s" % e) # XXX what exception if socket connection fails
finally:
self._write_lock.release()
return len(data)
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:18