diff options
Diffstat (limited to 'doc/examples/ex-client-x509.c')
-rw-r--r-- | doc/examples/ex-client-x509.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/examples/ex-client-x509.c b/doc/examples/ex-client-x509.c index 64e5eed4ad..07abcf015c 100644 --- a/doc/examples/ex-client-x509.c +++ b/doc/examples/ex-client-x509.c @@ -17,6 +17,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" @@ -101,9 +106,9 @@ int main(void) } /* send data */ - 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; |