mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Issue #8524: Add a forget() method to socket objects, so as to put the
socket into the closed state without closing the underlying file descriptor.
This commit is contained in:
parent
ba8a98600e
commit
e43f9d0ed6
6 changed files with 50 additions and 3 deletions
|
@ -655,6 +655,19 @@ class BasicTCPTest(SocketConnectedTest):
|
|||
self.serv_conn.send(MSG)
|
||||
self.serv_conn.shutdown(2)
|
||||
|
||||
def testForget(self):
|
||||
# Testing forget()
|
||||
f = self.cli_conn.fileno()
|
||||
self.cli_conn.forget()
|
||||
self.assertRaises(socket.error, self.cli_conn.recv, 1024)
|
||||
self.cli_conn.close()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
|
||||
msg = sock.recv(1024)
|
||||
self.assertEqual(msg, MSG)
|
||||
|
||||
def _testForget(self):
|
||||
self.serv_conn.send(MSG)
|
||||
|
||||
@unittest.skipUnless(thread, 'Threading required for this test.')
|
||||
class BasicUDPTest(ThreadedUDPSocketTest):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue