当前位置: 首页>>代码示例>>Python>>正文


Python socket.sendall方法代码示例

本文整理汇总了Python中socket.sendall方法的典型用法代码示例。如果您正苦于以下问题:Python socket.sendall方法的具体用法?Python socket.sendall怎么用?Python socket.sendall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socket的用法示例。


在下文中一共展示了socket.sendall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendAPRSPacket

# 需要导入模块: 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,代码来源:aprs.py

示例2: escape

# 需要导入模块: 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,代码来源:rfc2217.py

示例3: write

# 需要导入模块: 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,代码来源:rfc2217.py

示例4: escape

# 需要导入模块: 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 data:
            if byte == IAC:
                yield IAC
                yield IAC
            else:
                yield byte

    # - incoming data filter 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:18,代码来源:rfc2217.py

示例5: should_block_on_frame

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def should_block_on_frame(self, frame):
        if not should_debug_code(frame.f_code):
            return False
        # It is still possible that we're somewhere in standard library code, but that code was invoked by our
        # internal debugger machinery (e.g. socket.sendall or text encoding while tee'ing print output to VS).
        # We don't want to block on any of that, either, so walk the stack and see if we hit debugger frames
        # at some point below the non-debugger ones.
        while frame is not None:
            # There is usually going to be a debugger frame at the very bottom of the stack - the one that
            # invoked user code on this thread when starting debugging. If we reached that, then everything
            # above is user code, so we know that we do want to block here.
            if frame.f_code in DEBUG_ENTRYPOINTS:
                break
            # Otherwise, check if it's some other debugger code.
            filename = path.normcase(frame.f_code.co_filename)
            is_debugger_frame = False
            for debugger_file in DONT_DEBUG:
                if is_same_py_file(filename, debugger_file):
                    # If it is, then the frames above it on the stack that we have just walked through
                    # were for debugger internal purposes, and we do not want to block here.
                    return False
            frame = frame.f_back
        return True 
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:25,代码来源:visualstudio_py_debugger.py

示例6: send_and_receive

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def send_and_receive(self, socket, stream, save_cookies=False):
        res = []
        i = socket.sendall(self.serialize())
        if self.method == AjpForwardRequest.POST:
            return res

        r = AjpResponse.receive(stream)
        assert r.prefix_code == AjpResponse.SEND_HEADERS
        res.append(r)
        if save_cookies and 'Set-Cookie' in r.response_headers:
            self.headers['SC_REQ_COOKIE'] = r.response_headers['Set-Cookie']

        # read body chunks and end response packets
        while True:
            r = AjpResponse.receive(stream)
            res.append(r)
            if r.prefix_code == AjpResponse.END_RESPONSE:
                break
            elif r.prefix_code == AjpResponse.SEND_BODY_CHUNK:
                continue
            else:
                raise NotImplementedError
                break

        return res 
开发者ID:Ascotbe,项目名称:Medusa,代码行数:27,代码来源:TomcatUnauthorizedCommandExecutionVulnerability.py

示例7: send_and_receive

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def send_and_receive(self, socket, stream, save_cookies=False):
		res = []
		i = socket.sendall(self.serialize())
		if self.method == AjpForwardRequest.POST:
			return res

		r = AjpResponse.receive(stream)
		assert r.prefix_code == AjpResponse.SEND_HEADERS
		res.append(r)
		if save_cookies and 'Set-Cookie' in r.response_headers:
			self.headers['SC_REQ_COOKIE'] = r.response_headers['Set-Cookie']

		# read body chunks and end response packets
		while True:
			r = AjpResponse.receive(stream)
			res.append(r)
			if r.prefix_code == AjpResponse.END_RESPONSE:
				break
			elif r.prefix_code == AjpResponse.SEND_BODY_CHUNK:
				continue
			else:
				raise NotImplementedError
				break

		return res 
开发者ID:ym2011,项目名称:POC-EXP,代码行数:27,代码来源:CNVD-2020-10487-Tomcat-Ajp-lfi.py

示例8: write

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def write(self, data):
        """\
        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        """
        if not self.is_open:
            raise portNotOpenError
        with self._write_lock:
            try:
                self._socket.sendall(to_bytes(data).replace(IAC, IAC_DOUBLED))
            except socket.error as e:
                raise SerialException("connection failed (socket error): {}".format(e))
        return len(data) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:16,代码来源:rfc2217.py

示例9: _internal_raw_write

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        with self._write_lock:
            self._socket.sendall(data) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:6,代码来源:rfc2217.py

示例10: _send

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def _send(self, msg):
        """Sends the given message to the socket."""

        # socket.sendall() takes str in Python 2 and bytes in Python 3
        if sys.version_info[0] >= 3:
            msg = msg.encode()

        try:
            self._sock.sendall(msg)
        except socket.error as err:
            raise NagiosQueryError(err) 
开发者ID:m-lab,项目名称:prometheus-nagios-exporter,代码行数:13,代码来源:nagios_exporter.py

示例11: _internal_raw_write

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def _internal_raw_write(self, data):
        """internal socket write with no data escaping. used to send telnet stuff."""
        self._write_lock.acquire()
        try:
            self._socket.sendall(data)
        finally:
            self._write_lock.release() 
开发者ID:FSecureLABS,项目名称:Jandroid,代码行数:9,代码来源:rfc2217.py

示例12: broadcast_to_all_clients

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def broadcast_to_all_clients(self, senders_socket):
        for client in self.clients_list:
            socket, (ip, port) = client
            if socket is not senders_socket:
                socket.sendall(self.last_received_message.encode('utf-8')) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Blueprints-Second-Edition,代码行数:7,代码来源:9.09_chat_server.py

示例13: write

# 需要导入模块: 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(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:AstroPrint,项目名称:AstroBox,代码行数:16,代码来源:rfc2217.py

示例14: escape

# 需要导入模块: 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 data:
            if byte == IAC:
                yield IAC
                yield IAC
            else:
                yield byte

    # - incoming data filter 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:17,代码来源:rfc2217.py

示例15: output

# 需要导入模块: import socket [as 别名]
# 或者: from socket import sendall [as 别名]
def output(self, output_list):
        """Create a socket stream and send the payload as output."""
        separator = output_common.get_separator(self.options['separator'], self._SEPARATORS)
        line = separator.join([self.convert_item(item) for item in output_list])
        if self.options['final_separator']:
            line += separator
        protocol = Socket._VERSIONS[self.options['ip_version']]
        # TODO: handle exceptions?
        s = socket.socket(protocol, socket.SOCK_STREAM)
        s.connect((self.options['host'], self.options['port']))
        if self.options['await_banner']:
            s.recv(Socket._BANNER_LENGTH)
        s.sendall(line)
        s.close() 
开发者ID:twosixlabs,项目名称:acsploit,代码行数:16,代码来源:socket.py


注:本文中的socket.sendall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。