(self)
| 96 | |
| 97 | if PLATFORM == "linux": |
| 98 | def get_backlog(self): |
| 99 | if self.sock: |
| 100 | # tcp_info struct from include/uapi/linux/tcp.h |
| 101 | fmt = 'B' * 8 + 'I' * 24 |
| 102 | try: |
| 103 | tcp_info_struct = self.sock.getsockopt(socket.IPPROTO_TCP, |
| 104 | socket.TCP_INFO, 104) |
| 105 | # 12 is tcpi_unacked |
| 106 | return struct.unpack(fmt, tcp_info_struct)[12] |
| 107 | except (AttributeError, OSError): |
| 108 | pass |
| 109 | return 0 |
| 110 | else: |
| 111 | def get_backlog(self): |
| 112 | return -1 |