(self)
| 3771 | |
| 3772 | @requireAttrs(socket, "MSG_PEEK") |
| 3773 | def testRecvmsgPeek(self): |
| 3774 | # Check that MSG_PEEK in flags enables examination of pending |
| 3775 | # data without consuming it. |
| 3776 | |
| 3777 | # Receive part of data with MSG_PEEK. |
| 3778 | msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, |
| 3779 | len(MSG) - 3, 0, |
| 3780 | socket.MSG_PEEK) |
| 3781 | self.assertEqual(msg, MSG[:-3]) |
| 3782 | self.checkRecvmsgAddress(addr, self.cli_addr) |
| 3783 | self.assertEqual(ancdata, []) |
| 3784 | # Ignoring MSG_TRUNC here (so this test is the same for stream |
| 3785 | # and datagram sockets). Some wording in POSIX seems to |
| 3786 | # suggest that it needn't be set when peeking, but that may |
| 3787 | # just be a slip. |
| 3788 | self.checkFlags(flags, eor=False, |
| 3789 | ignore=getattr(socket, "MSG_TRUNC", 0)) |
| 3790 | |
| 3791 | # Receive all data with MSG_PEEK. |
| 3792 | msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, |
| 3793 | len(MSG), 0, |
| 3794 | socket.MSG_PEEK) |
| 3795 | self.assertEqual(msg, MSG) |
| 3796 | self.checkRecvmsgAddress(addr, self.cli_addr) |
| 3797 | self.assertEqual(ancdata, []) |
| 3798 | self.checkFlags(flags, eor=True) |
| 3799 | |
| 3800 | # Check that the same data can still be received normally. |
| 3801 | msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock, len(MSG)) |
| 3802 | self.assertEqual(msg, MSG) |
| 3803 | self.checkRecvmsgAddress(addr, self.cli_addr) |
| 3804 | self.assertEqual(ancdata, []) |
| 3805 | self.checkFlags(flags, eor=True) |
| 3806 | |
| 3807 | @testRecvmsgPeek.client_skip |
| 3808 | def _testRecvmsgPeek(self): |
nothing calls this directly
no test coverage detected