當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。