summaryrefslogtreecommitdiff
path: root/examples/c-simple
diff options
context:
space:
mode:
Diffstat (limited to 'examples/c-simple')
-rw-r--r--examples/c-simple/c-simple.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/examples/c-simple/c-simple.c b/examples/c-simple/c-simple.c
index 6e7d0f66d..8d723fe20 100644
--- a/examples/c-simple/c-simple.c
+++ b/examples/c-simple/c-simple.c
@@ -159,8 +159,7 @@ static void simple_flow_cleanup_callback(struct nDPIsrvd_socket * const sock,
if (reason == CLEANUP_REASON_FLOW_TIMEOUT)
{
- fprintf(stderr, "Flow timeout occurred, something really bad happened.\n");
- exit(1);
+ fprintf(stderr, "Flow %llu timeouted.\n", flow->id_as_ull);
}
}
@@ -188,9 +187,27 @@ int main(int argc, char ** argv)
return 1;
}
+ if (nDPIsrvd_set_read_timeout(sock, 3, 0) != 0)
+ {
+ return 1;
+ }
+
enum nDPIsrvd_read_return read_ret;
- while (main_thread_shutdown == 0 && (read_ret = nDPIsrvd_read(sock)) == READ_OK)
+ while (main_thread_shutdown == 0)
{
+ read_ret = nDPIsrvd_read(sock);
+ if (read_ret == READ_TIMEOUT)
+ {
+ printf("No data received during the last %llu second(s).\n",
+ (long long unsigned int)sock->read_timeout.tv_sec);
+ continue;
+ }
+ if (read_ret != READ_OK)
+ {
+ main_thread_shutdown = 1;
+ continue;
+ }
+
enum nDPIsrvd_parse_return parse_ret = nDPIsrvd_parse_all(sock);
if (parse_ret != PARSE_NEED_MORE_DATA)
{