(self, sock, bound=False)
| 40 | return getattr(self.sock, name) |
| 41 | |
| 42 | def set_options(self, sock, bound=False): |
| 43 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
| 44 | if (self.conf.reuse_port |
| 45 | and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover |
| 46 | try: |
| 47 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) |
| 48 | except OSError as err: |
| 49 | if err.errno not in (errno.ENOPROTOOPT, errno.EINVAL): |
| 50 | raise |
| 51 | if not bound: |
| 52 | self.bind(sock) |
| 53 | sock.setblocking(0) |
| 54 | |
| 55 | # make sure that the socket can be inherited |
| 56 | if hasattr(sock, "set_inheritable"): |
| 57 | sock.set_inheritable(True) |
| 58 | |
| 59 | sock.listen(self.conf.backlog) |
| 60 | return sock |
| 61 | |
| 62 | def bind(self, sock): |
| 63 | sock.bind(self.cfg_addr) |
no test coverage detected