• Home
  • Raw
  • Download

Lines Matching +full:getsockopt +full:- +full:timeouts

42 MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
203 """Subclass of unittest.TestCase with thread-safe cleanup methods.
523 """Socket tests for client-server connection.
579 # gives a drop-in replacement for SocketConnectedTest, but different
682 """Base class for Unix-domain socket tests."""
700 """Base class for Unix-domain SOCK_STREAM tests."""
719 """Base class for TCP-over-IPv4 tests."""
725 """Base class for UDP-over-IPv4 tests."""
731 """Base class for UDPLITE-over-IPv4 tests."""
737 """Base class for SCTP tests in one-to-one (SOCK_STREAM) mode."""
750 """Base class for UDP-over-IPv6 tests."""
756 """Base class for UDPLITE-over-IPv6 tests."""
762 # Test-skipping decorators for use with ThreadableTest.
860 expected = ('<socket object, fd=-1, family=%s, type=%s, proto=%s>'
897 "a bytes-like object is required, not 'str'")
901 "a bytes-like object is required, not 'complex'")
909 "a bytes-like object is required, not 'str'")
913 "a bytes-like object is required, not 'complex'")
1014 # a matching name entry (e.g. 'ip6-localhost')
1060 # interface indices are non-zero integers
1107 mask = (1<<size) - 1
1120 l_bad_values = [-1, -2, 1<<32, 1<<1000]
1123 [_testcapi.INT_MIN-1, _testcapi.INT_MAX+1] +
1147 # assumption breaking non-standard port/protocol entry
1180 self.assertRaises(OverflowError, socket.getservbyport, -1)
1203 self.assertRaises(ValueError, socket.setdefaulttimeout, -1)
1231 # bpo-29972: inet_pton() doesn't fail on AIX
1291 # bpo-29972: inet_pton() doesn't fail on AIX
1373 # XXX The following don't test module-level functionality...
1394 # Testing getsockopt()
1398 reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
1406 reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
1445 neg_port = port - 65536
1469 self.assertRaises(ValueError, s.ioctl, -1, None)
1645 self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
1672 socket.close(-1)
1678 encoding = None if "b" in mode else "utf-8"
1701 for backlog in 0, -1:
1723 self.assertRaises(OverflowError, s.bind, (socket_helper.HOSTv6, 0, -10))
1791 # Make sure that the AF_* and SOCK_* constants have enum-like string
1910 socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=-1)
1912 @unittest.skipIf(os.name == "nt", "Windows disallows -1 only")
1915 socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=-42)
2013 s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_LOOPBACK))
2023 s.getsockopt(socket.SOL_CAN_RAW, socket.CAN_RAW_FILTER, 8))
2326 self.assertRaises(OSError, socket_helper.bind_port, s, host=-2)
2357 orig_max = s.getsockopt(socket.AF_VSOCK,
2359 orig = s.getsockopt(socket.AF_VSOCK,
2361 orig_min = s.getsockopt(socket.AF_VSOCK,
2372 s.getsockopt(socket.AF_VSOCK,
2375 s.getsockopt(socket.AF_VSOCK,
2378 s.getsockopt(socket.AF_VSOCK,
2436 seg1 = self.cli_conn.recv(len(MSG) - 3)
2454 seg1, addr = self.cli_conn.recvfrom(len(MSG)-3)
2567 self.assertRaises(ValueError, self.serv.recvfrom, -1)
2598 self.assertRaises(ValueError, self.serv.recvfrom, -1)
2660 # recvmsg() or recvmsg_into() - RecvmsgIntoMixin overrides
2778 # Base class for tests on connectionless-mode sockets. Users must
2972 # bpo-33937 the test randomly fails on Travis CI with
2988 # Check that MSG_DONTWAIT in flags causes non-blocking behaviour.
2998 # bpo-33937: catch also ENOMEM, the test randomly fails on Travis CI
3007 # Tests for sendmsg() which require a connectionless-mode
3065 len(MSG) - 3)
3066 self.assertEqual(msg, MSG[:-3])
3125 len(MSG) - 3, 0,
3127 self.assertEqual(msg, MSG[:-3])
3178 # Receive end-of-stream indicator (b"", peer socket closed).
3183 self.checkFlags(flags, eor=None) # Might not have end-of-record marker
3191 len(MSG) - 3)
3215 -1, 0, 0)
3217 len(MSG), -1, 0)
3255 [buf], -1, 0)
3300 b1 = bytearray(b"----")
3302 b3 = bytearray(b"--------------")
3308 self.assertEqual(b3, bytearray(b"little lamb---"))
3334 toobig = self.socklen_t_limit - socket.CMSG_LEN(0) + 1
3335 values = list(range(257)) + list(range(toobig - 257, toobig))
3342 self.assertEqual(ret - socket.CMSG_LEN(0), n)
3345 self.assertRaises(OverflowError, socket.CMSG_LEN, -1)
3355 toobig = self.socklen_t_limit - socket.CMSG_SPACE(1) + 1
3356 values = list(range(257)) + list(range(toobig - 257, toobig))
3369 self.assertRaises(OverflowError, socket.CMSG_SPACE, -1)
3377 # Tests for file descriptor passing on Unix-domain sockets.
3382 badfd = -0x5555
3385 # Return a list of n file descriptors for newly-created files
3414 len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
3420 # server, with the constant MSG as the non-ancillary data.
3594 array.array("i", [self.badfd]).tobytes()[:-1])])
3611 len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
3622 array.array("i", [fd0, self.badfd]).tobytes()[:-1]),
3657 # Check that no ancillary data is returned for various non-zero
3678 socket.CMSG_LEN(0) - 1))
3707 len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
3730 self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1,
3731 maxdata=(2 * SIZEOF_INT) - 1)
3751 # -1 means "use kernel default".
3752 traffic_class = -1
3996 # Check that no ancillary data is returned for various non-zero
4019 self.checkHopLimitTruncatedHeader(ancbufsize=socket.CMSG_LEN(0) - 1)
4035 self.serv_sock, len(MSG), socket.CMSG_LEN(SIZEOF_INT) - 1)
4121 socket.CMSG_LEN(0) - 1)
4140 socket.CMSG_SPACE(SIZEOF_INT) + socket.CMSG_LEN(SIZEOF_INT) - 1)
4198 self.assertEqual(addr1[:-1], addr2[:-1])
4271 self.assertEqual(addr1[:-1], addr2[:-1])
4361 self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876")
4375 self.skipTest("sporadic ENOTCONN (kernel issue?) - see issue #13876")
4538 # sendto() doesn't allow passing a zero-length one; POSIX
4540 # connection-mode, however.
4618 # When a Python socket has a non-zero timeout, it's switched
4619 # internally to a non-blocking mode. Later, sock.sendall(),
4622 # timeouts are enforced.
4680 # bpo-7995: accept() on a listening socket with a timeout and the
4692 # bpo-7995: accept() on a listening socket with a timeout and the
4706 # Testing non-blocking accept
4709 # connect() didn't start: non-blocking accept() fails
4713 dt = time.monotonic() - start_time
4722 # connect() completed: non-blocking accept() doesn't block
4729 # that non-blocking accept() raises BlockingIOError
4735 # Testing non-blocking recv
4740 # the server didn't send data yet: non-blocking recv() fails
4748 self.fail("Error during select call to non-blocking socket.")
4750 # the server sent data yet: non-blocking recv() doesn't block
4758 # that non-blocking recv() raises BlockingIOError
4777 bufsize = -1 # Use default buffer size
4778 encoding = 'utf-8'
4841 first_seg = self.read_file.read(len(self.read_msg)-3)
4970 self.assertEqual(refcount_before - 1, refcount_after)
4975 # Non-blocking ops
4976 # NOTE: to set `read_file` as non-blocking, we must call
4977 # `cli_conn.setblocking` and vice-versa (see setUp / clientSetUp).
4982 self.assertEqual(self.read_file.read(len(self.read_msg) - 3), None)
4985 first_seg = self.read_file.read(len(self.read_msg) - 3)
4989 first_seg = self.read_file.read(len(self.read_msg) - 3)
5009 # The client thread can't skip directly - the SkipTest exception
5038 bufsize = 1 # Default-buffered for reading; line-buffered for writing
5050 read_msg = MSG.decode('utf-8')
5062 write_msg = MSG.decode('utf-8')
5070 read_msg = MSG.decode('utf-8')
5072 write_msg = MSG.decode('utf-8')
5388 address = b"\x00python-test-hello\x00\xff"
5399 address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1)
5475 # Test binding to a valid non-ASCII pathname, with the
5476 # non-ASCII bytes supplied using surrogateescape encoding.
5590 f = open("/proc/modules", encoding="utf-8")
5616 TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0)
5652 TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0)
5794 # "blocking" Python sockets *with timeouts* are in a
5795 # *non-blocking* mode, and 'sock.recv()' uses 'select()'
5895 self.assertRaises(ValueError, socket.fromshare, data[:-1])
5958 total -= step
6058 self.assertEqual(sent, self.FILESIZE - 5000)
6064 self.assertEqual(len(data), self.FILESIZE - 5000)
6144 # timeout (non-triggered)
6188 with open(os_helper.TESTFN, encoding="utf-8") as file:
6203 meth, file, count=-1)
6230 # bpo-31705: On kernel older than 4.5, sendto() failed with ENOKEY,
6260 # Ubuntu 15.10 with Kernel 4.2.0-19.
6327 self.assertEqual(expected_ct, res[assoclen:-taglen])
6328 self.assertEqual(expected_tag, res[-taglen:])
6337 self.assertEqual(expected_ct, res[assoclen:-taglen])
6338 self.assertEqual(expected_tag, res[-taglen:])
6353 self.assertEqual(expected_ct, res[assoclen:-taglen])
6354 self.assertEqual(expected_tag, res[-taglen:])
6362 res = op.recv(len(msg) - taglen)
6392 sock.sendmsg_afalg(op=socket.ALG_OP_ENCRYPT, assoclen=-1)
6395 # bpo-35050, off-by-one error in length check
6438 "New TCP flags were discovered. See bpo-32394 for more information")
6469 opt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
6472 opt = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT)
6481 assert sock.getsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY)
6534 # --- dual stack tests