nDPIsrvd.(h|py): Added socket read/recv timeout.

* nDPIsrvd.h: support for O_NONBLOCK nDPIsrvd_socket

Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
lns
2022-04-17 18:56:30 +02:00
parent a2547321bb
commit c7bf94e9f1
7 changed files with 97 additions and 18 deletions

View File

@@ -426,8 +426,16 @@ if __name__ == '__main__':
nsock = nDPIsrvdSocket()
nsock.connect(address)
nsock.timeout(1.0)
stats = Stats(nsock)
try:
nsock.loop(onJsonLineRecvd, onFlowCleanup, stats)
except KeyboardInterrupt:
print('\n\nKeyboard Interrupt: cleaned up {} flows.'.format(len(nsock.shutdown())))
while True:
try:
nsock.loop(onJsonLineRecvd, onFlowCleanup, stats)
except KeyboardInterrupt:
print('\n\nKeyboard Interrupt: cleaned up {} flows.'.format(len(nsock.shutdown())))
break
except TimeoutError:
stats.updateSpinner()
stats.resetStatus()
stats.printStatus()