Util to send/receive packets, used by sr*(). Do not use directly. This matches the requests and answers. Notes:: - threaded: if you're planning to send/receive many packets, it's likely a good idea to use threaded mode. - DEVS: store the outgoing timestamp righ
| 105 | |
| 106 | |
| 107 | class SndRcvHandler(object): |
| 108 | """ |
| 109 | Util to send/receive packets, used by sr*(). |
| 110 | Do not use directly. |
| 111 | |
| 112 | This matches the requests and answers. |
| 113 | |
| 114 | Notes:: |
| 115 | - threaded: if you're planning to send/receive many packets, it's likely |
| 116 | a good idea to use threaded mode. |
| 117 | - DEVS: store the outgoing timestamp right BEFORE sending the packet |
| 118 | to avoid races that could result in negative latency. We aren't Stadia |
| 119 | """ |
| 120 | def __init__(self, |
| 121 | pks, # type: SuperSocket |
| 122 | pkt, # type: _PacketIterable |
| 123 | timeout=None, # type: Optional[int] |
| 124 | inter=0, # type: int |
| 125 | verbose=None, # type: Optional[int] |
| 126 | chainCC=False, # type: bool |
| 127 | retry=0, # type: int |
| 128 | multi=False, # type: bool |
| 129 | first=False, # type: bool |
| 130 | rcv_pks=None, # type: Optional[SuperSocket] |
| 131 | prebuild=False, # type: bool |
| 132 | _flood=None, # type: Optional[_FloodGenerator] |
| 133 | threaded=True, # type: bool |
| 134 | session=None, # type: Optional[_GlobSessionType] |
| 135 | chainEX=False, # type: bool |
| 136 | stop_filter=None # type: Optional[Callable[[Packet], bool]] |
| 137 | ): |
| 138 | # type: (...) -> None |
| 139 | # Instantiate all arguments |
| 140 | if verbose is None: |
| 141 | verbose = conf.verb |
| 142 | if conf.debug_match: |
| 143 | debug.recv = PacketList([], "Received") |
| 144 | debug.sent = PacketList([], "Sent") |
| 145 | debug.match = SndRcvList([], "Matched") |
| 146 | self.nbrecv = 0 |
| 147 | self.ans = [] # type: List[QueryAnswer] |
| 148 | self.pks = pks |
| 149 | self.rcv_pks = rcv_pks or pks |
| 150 | self.inter = inter |
| 151 | self.verbose = verbose |
| 152 | self.chainCC = chainCC |
| 153 | self.multi = multi |
| 154 | self.timeout = timeout |
| 155 | self.first = first |
| 156 | self.session = session |
| 157 | self.chainEX = chainEX |
| 158 | self.stop_filter = stop_filter |
| 159 | self._send_done = False |
| 160 | self.notans = 0 |
| 161 | self.noans = 0 |
| 162 | self._flood = _flood |
| 163 | self.threaded = threaded |
| 164 | self.breakout = Event() |
no outgoing calls
no test coverage detected
searching dependent graphs…