From dc4ed5a7b59f1d5b4e4f7fb4b6e29ecaf5e6cc5c Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Mon, 16 Apr 2012 07:47:00 +0200 Subject: XS_SURVEY_TIMEOUT socket option added. It can be used to timeout the survey. Value is in milliseconds and -1 means infinite (default). Signed-off-by: Martin Sustrik --- tests/survey.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/survey.cpp b/tests/survey.cpp index 41f39aa..c6b3131 100644 --- a/tests/survey.cpp +++ b/tests/survey.cpp @@ -118,6 +118,18 @@ int XS_TEST_MAIN () rc = xs_recv (surveyor, buf, sizeof (buf), 0); assert (rc == 4); + // Now let's test whether survey timeout works as expected. + int timeout = 100; + rc = xs_setsockopt (surveyor, XS_SURVEY_TIMEOUT, &timeout, sizeof (int)); + assert (rc == 0); + rc = xs_send (surveyor, "ABC", 3, 0); + assert (rc == 3); + void *watch = xs_stopwatch_start (); + rc = xs_recv (surveyor, buf, sizeof (buf), 0); + assert (rc == - 1 && errno == EAGAIN); + unsigned long elapsed = xs_stopwatch_stop (watch) / 1000; + time_assert (elapsed, (unsigned long) timeout); + rc = xs_close (respondent2); assert (rc == 0); rc = xs_close (respondent1); -- cgit v1.2.3