當前位置: 首頁>>代碼示例>>Python>>正文


Python errno.WSAENOTSOCK屬性代碼示例

本文整理匯總了Python中errno.WSAENOTSOCK屬性的典型用法代碼示例。如果您正苦於以下問題:Python errno.WSAENOTSOCK屬性的具體用法?Python errno.WSAENOTSOCK怎麽用?Python errno.WSAENOTSOCK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在errno的用法示例。


在下文中一共展示了errno.WSAENOTSOCK屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_invalidDescriptor

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def test_invalidDescriptor(self):
        """
        An implementation of L{IReactorSocket.adoptStreamPort} raises
        L{socket.error} if passed an integer which is not associated with a
        socket.
        """
        reactor = self.buildReactor()

        probe = socket.socket()
        fileno = probe.fileno()
        probe.close()

        exc = self.assertRaises(
            socket.error,
            reactor.adoptStreamPort, fileno, socket.AF_INET, ServerFactory())
        if platform.isWindows() and _PY3:
            self.assertEqual(exc.args[0], errno.WSAENOTSOCK)
        else:
            self.assertEqual(exc.args[0], errno.EBADF) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:21,代碼來源:test_socket.py

示例2: getHandleErrorCode

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def getHandleErrorCode(self):
        """
        Return the argument L{SSL.Error} will be constructed with for this
        case.  This is basically just a random OpenSSL implementation detail.
        It would be better if this test worked in a way which did not require
        this.
        """
        # Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
        # SSL.Connection.write for some reason.  The twisted.protocols.tls
        # implementation of IReactorSSL doesn't suffer from this imprecation,
        # though, since it is isolated from the Windows I/O layer (I suppose?).

        # If test_properlyCloseFiles waited for the SSL handshake to complete
        # and performed an orderly shutdown, then this would probably be a
        # little less weird: writing to a shutdown SSL connection has a more
        # well-defined failure mode (or at least it should).
        name = fullyQualifiedName(getClass(reactor))
        if platform.getType() == 'win32' and name != self._iocp:
            return errno.WSAENOTSOCK
        # This is terribly implementation-specific.
        return [('SSL routines', 'SSL_write', 'protocol is shutdown')] 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:23,代碼來源:test_ssl.py

示例3: getHandleErrorCode

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def getHandleErrorCode(self):
        """
        Return the errno expected to result from writing to a closed
        platform socket handle.
        """
        # Windows and Python 3: returns WSAENOTSOCK
        # Windows and Python 2: returns EBADF
        # Linux, FreeBSD, Mac OS X: returns EBADF
        if platform.isWindows() and _PY3:
            return errno.WSAENOTSOCK
        return errno.EBADF 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:test_tcp.py

示例4: getHandleErrorCode

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def getHandleErrorCode(self):
        """
        Return the argument L{OpenSSL.SSL.Error} will be constructed with for
        this case. This is basically just a random OpenSSL implementation
        detail. It would be better if this test worked in a way which did not
        require this.
        """
        # Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
        # SSL.Connection.write for some reason.  The twisted.protocols.tls
        # implementation of IReactorSSL doesn't suffer from this imprecation,
        # though, since it is isolated from the Windows I/O layer (I suppose?).

        # If test_properlyCloseFiles waited for the SSL handshake to complete
        # and performed an orderly shutdown, then this would probably be a
        # little less weird: writing to a shutdown SSL connection has a more
        # well-defined failure mode (or at least it should).

        # So figure out if twisted.protocols.tls is in use.  If it can be
        # imported, it should be.
        if requireModule('twisted.protocols.tls') is None:
            # It isn't available, so we expect WSAENOTSOCK if we're on Windows.
            if platform.getType() == 'win32':
                return errno.WSAENOTSOCK

        # Otherwise, we expect an error about how we tried to write to a
        # shutdown connection.  This is terribly implementation-specific.
        return [('SSL routines', 'SSL_write', 'protocol is shutdown')] 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:29,代碼來源:test_ssl.py

示例5: getHandleErrorCodeMatcher

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def getHandleErrorCodeMatcher(self):
        """
        Return a L{hamcrest.core.matcher.Matcher} that matches the
        errno expected to result from writing to a closed platform
        socket handle.
        """
        # Windows and Python 3: returns WSAENOTSOCK
        # Windows and Python 2: returns EBADF
        # Linux, FreeBSD, macOS: returns EBADF
        if platform.isWindows() and _PY3:
            return hamcrest.equal_to(errno.WSAENOTSOCK)
        return hamcrest.equal_to(errno.EBADF) 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:14,代碼來源:test_tcp.py

示例6: start_open_files_server

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import WSAENOTSOCK [as 別名]
def start_open_files_server(self):
        self.open_files_server.setsockopt(socket.SOL_SOCKET,
                                          socket.SO_REUSEADDR, 1)
        port = select_port(default_port=OPEN_FILES_PORT)
        CONF.set('main', 'open_files_port', port)
        self.open_files_server.bind(('127.0.0.1', port))
        self.open_files_server.listen(20)
        while 1:  # 1 is faster than True
            try:
                req, dummy = self.open_files_server.accept()
            except socket.error as e:
                # See Issue 1275 for details on why errno EINTR is
                # silently ignored here.
                eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR
                # To avoid a traceback after closing on Windows
                if e.args[0] == eintr:
                    continue
                # handle a connection abort on close error
                enotsock = (errno.WSAENOTSOCK if os.name == 'nt'
                            else errno.ENOTSOCK)
                if e.args[0] in [errno.ECONNABORTED, enotsock]:
                    return
                raise
            fname = req.recv(1024)
            fname = fname.decode('utf-8')
            self.sig_open_external_file.emit(fname)
            req.sendall(b' ')

    # ---- Quit and restart, and reset spyder defaults 
開發者ID:sys-bio,項目名稱:tellurium,代碼行數:31,代碼來源:mainwindow.py


注:本文中的errno.WSAENOTSOCK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。