(self)
| 6724 | s.close() |
| 6725 | |
| 6726 | def testShare(self): |
| 6727 | # Transfer the listening server socket to another process |
| 6728 | # and service it from there. |
| 6729 | |
| 6730 | # Create process: |
| 6731 | q = multiprocessing.Queue() |
| 6732 | p = multiprocessing.Process(target=self.remoteProcessServer, args=(q,)) |
| 6733 | p.start() |
| 6734 | |
| 6735 | # Get the shared socket data |
| 6736 | data = self.serv.share(p.pid) |
| 6737 | |
| 6738 | # Pass the shared socket to the other process |
| 6739 | addr = self.serv.getsockname() |
| 6740 | self.serv.close() |
| 6741 | q.put(data) |
| 6742 | |
| 6743 | # The data that the server will send us |
| 6744 | message = b"slapmahfro" |
| 6745 | q.put(message) |
| 6746 | |
| 6747 | # Connect |
| 6748 | s = socket.create_connection(addr) |
| 6749 | # listen for the data |
| 6750 | m = [] |
| 6751 | while True: |
| 6752 | data = s.recv(100) |
| 6753 | if not data: |
| 6754 | break |
| 6755 | m.append(data) |
| 6756 | s.close() |
| 6757 | received = b"".join(m) |
| 6758 | self.assertEqual(received, message) |
| 6759 | p.join() |
| 6760 | |
| 6761 | def testShareLength(self): |
| 6762 | data = self.serv.share(os.getpid()) |
nothing calls this directly
no test coverage detected