Update receive modes authored by Marlene Böhmer's avatar Marlene Böhmer
...@@ -16,4 +16,22 @@ Each mode comes with the following calls: ...@@ -16,4 +16,22 @@ Each mode comes with the following calls:
* `receive_[mode](...)`: Non-blocking call that returns an available packet or NULL. * `receive_[mode](...)`: Non-blocking call that returns an available packet or NULL.
* `receive_[mode]_wait(...)`: Blocking call that waits for until a single packet is available and returns it. * `receive_[mode]_wait(...)`: Blocking call that waits for until a single packet is available and returns it.
* `receive_[mode]_timedwait(..., deadline)`: Blocking call that waits until a packet is available and returns it or until `deadline`, in which case it returns NULL. * `receive_[mode]_timedwait(..., deadline)`: Blocking call that waits until a packet is available and returns it or until `deadline`, in which case a TimeoutException is raised.
\ No newline at end of file
## Examples
Ordered receive modes require a time window:
```python
data, addr = self.socket.receive_ordered(window)
```
A timedwait receive requires a utc deadline and needs some exeption handling:
```python
deadline = datetime.datetime.utcnow() + datetime.timedelta(seconds=delta)
try:
data, addr = self.socket.receive_asap_timedwait(deadline)
except prrt.TimeoutException:
pass
```
\ No newline at end of file