summaryrefslogtreecommitdiff
path: root/doc/examples/ex-client-resume.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples/ex-client-resume.c')
-rw-r--r--doc/examples/ex-client-resume.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/doc/examples/ex-client-resume.c b/doc/examples/ex-client-resume.c
index cf67bfcf1b..3161ef3165 100644
--- a/doc/examples/ex-client-resume.c
+++ b/doc/examples/ex-client-resume.c
@@ -21,6 +21,11 @@ extern void tcp_close(int sd);
*/
#define CHECK(x) assert((x)>=0)
+#define LOOP_CHECK(rval, cmd) \
+ do { \
+ rval = cmd; \
+ } while(rval == GNUTLS_E_AGAIN || rval == GNUTLS_E_INTERRUPTED); \
+ assert(rval >= 0)
#define MAX_BUF 1024
#define MSG "GET / HTTP/1.0\r\n\r\n"
@@ -51,9 +56,9 @@ int main(void)
CHECK(gnutls_init(&session, GNUTLS_CLIENT));
CHECK(gnutls_server_name_set(session, GNUTLS_NAME_DNS,
- "my_host_name",
- strlen("my_host_name")));
- gnutls_session_set_verify_cert(session, "my_host_name", 0);
+ "www.example.com",
+ strlen("www.example.com")));
+ gnutls_session_set_verify_cert(session, "www.example.com", 0);
CHECK(gnutls_set_default_priority(session));
@@ -100,9 +105,9 @@ int main(void)
}
}
- gnutls_record_send(session, MSG, strlen(MSG));
+ LOOP_CHECK(ret, gnutls_record_send(session, MSG, strlen(MSG)));
- ret = gnutls_record_recv(session, buffer, MAX_BUF);
+ LOOP_CHECK(ret, gnutls_record_recv(session, buffer, MAX_BUF));
if (ret == 0) {
printf("- Peer has closed the TLS connection\n");
goto end;