summaryrefslogtreecommitdiffstats
path: root/demos/guide/tls-client-non-block.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/guide/tls-client-non-block.c')
-rw-r--r--demos/guide/tls-client-non-block.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/demos/guide/tls-client-non-block.c b/demos/guide/tls-client-non-block.c
index 05db0f529e..dc6ee4dce8 100644
--- a/demos/guide/tls-client-non-block.c
+++ b/demos/guide/tls-client-non-block.c
@@ -111,9 +111,21 @@ static void wait_for_activity(SSL *ssl, int write)
width = sock + 1;
/*
- * Wait until the socket is writeable or readable. We use select here for
- * the sake of simplicity and portability, but you could equally use
+ * Wait until the socket is writeable or readable. We use select here
+ * for the sake of simplicity and portability, but you could equally use
* poll/epoll or similar functions
+ *
+ * NOTE: For the purposes of this demonstration code this effectively
+ * makes this demo block until it has something more useful to do. In a
+ * real application you probably want to go and do other work here (e.g.
+ * update a GUI, or service other connections).
+ *
+ * Let's say for example that you want to update the progress counter on
+ * a GUI every 100ms. One way to do that would be to add a 100ms timeout
+ * in the last parameter to "select" below. Then, when select returns,
+ * you check if it did so because of activity on the file descriptors or
+ * because of the timeout. If it is due to the timeout then update the
+ * GUI and then restart the "select".
*/
if (write)
select(width, NULL, &fds, NULL, NULL);