diff options
Diffstat (limited to 'doc/examples/ex-client-psk.c')
-rw-r--r-- | doc/examples/ex-client-psk.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/examples/ex-client-psk.c b/doc/examples/ex-client-psk.c index 4b393d877f..63ef884c70 100644 --- a/doc/examples/ex-client-psk.c +++ b/doc/examples/ex-client-psk.c @@ -18,6 +18,11 @@ */ #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" @@ -95,9 +100,9 @@ int main(void) gnutls_free(desc); } - CHECK(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; |