Python errno.WSAENOTSOCK Examples
The following are 10
code examples of errno.WSAENOTSOCK().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
errno
, or try the search function
.
Example #1
Source File: test_socket.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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)
Example #2
Source File: test_socket.py From learn_python3_spider with MIT License | 6 votes |
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)
Example #3
Source File: test_socket.py From learn_python3_spider with MIT License | 6 votes |
def test_invalidDescriptor(self): """ An implementation of L{IReactorSocket.adoptDatagramPort} 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.adoptDatagramPort, fileno, socket.AF_INET, DatagramProtocol()) if platform.isWindows() and _PY3: self.assertEqual(exc.args[0], errno.WSAENOTSOCK) else: self.assertEqual(exc.args[0], errno.EBADF)
Example #4
Source File: test_ssl.py From python-for-android with Apache License 2.0 | 6 votes |
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')]
Example #5
Source File: test_socket.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def test_invalidDescriptor(self): """ An implementation of L{IReactorSocket.adoptDatagramPort} 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.adoptDatagramPort, fileno, socket.AF_INET, DatagramProtocol()) if platform.isWindows() and _PY3: self.assertEqual(exc.args[0], errno.WSAENOTSOCK) else: self.assertEqual(exc.args[0], errno.EBADF)
Example #6
Source File: test_tcp.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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
Example #7
Source File: test_ssl.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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')]
Example #8
Source File: test_tcp.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #9
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
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
Example #10
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
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