26 tv.tv_sec = (time_t)t; tv.tv_usec = 0;
29 switch (SSL_get_error(
ssl,r)) {
31 case SSL_ERROR_WANT_READ:
32 FD_SET(rfd,&
fds); n = select(rfd + 1,&
fds,NULL,NULL,&tv);
34 case SSL_ERROR_WANT_WRITE:
35 FD_SET(wfd,&
fds); n = select(wfd + 1,NULL,&
fds,NULL,&tv);
42 if (n != -1) errno = ETIMEDOUT;
51 if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1)
return -1;
54 if (r <= 0) { ndelay_off(rfd); ndelay_off(wfd); }
55 else SSL_set_mode(
ssl,SSL_MODE_ENABLE_PARTIAL_WRITE);
65 if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1)
return -1;
68 if (r <= 0) { ndelay_off(rfd); ndelay_off(wfd); }
69 else SSL_set_mode(
ssl,SSL_MODE_ENABLE_PARTIAL_WRITE);
81 if (SSL_get_state(
ssl) & SSL_ST_CONNECT)
return -2;
84 SSL_set_connect_state(
ssl);
92 if (SSL_pending(
ssl))
return SSL_read(
ssl,
buf,len);
int tls_timeoutconn(int t, int rfd, int wfd, SSL *ssl)
int tls_timeoutwrite(int t, int rfd, int wfd, SSL *ssl, char *buf, int len)
int tls_timeoutaccept(int t, int rfd, int wfd, SSL *ssl)
int tls_timeoutrehandshake(int t, int rfd, int wfd, SSL *ssl)
int tls_timeoutread(int t, int rfd, int wfd, SSL *ssl, char *buf, int len)
int tls_timeoutio(int(*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, int len)