Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int mbedtls_tls_recv_timeout( void *ctx, unsigned char *buf, size_t len,
- uint32_t timeout )
- {
- int ret, err;
- struct timeval tv;
- fd_set read_fds;
- struct fns_timeval tv_fns;
- fns_fd_set read_fds_fns;
- int fd = ((mbedtls_net_context *) ctx)->fd;
- if( fd < 0 )
- return( MBEDTLS_ERR_NET_INVALID_CONTEXT );
- if(ipv6)
- {
- FD_ZERO( &read_fds_fns );
- FD_SET( fd, &read_fds_fns );
- tv_fns.tv_sec = 10;
- tv_fns.tv_usec = 0;
- ret = fnsSelect( fd + 1, &read_fds_fns, NULL, NULL, &tv_fns, (int*)&err );
- }
- else
- {
- FD_ZERO( &read_fds );
- FD_SET( fd, &read_fds );
- tv.tv_sec = 10;
- tv.tv_usec = 0;
- ret = select( fd + 1, &read_fds, NULL, NULL, &tv );
- }
- /* Zero fds ready means we timed out */
- if( ret == 0 ) {
- FTP_DEBUG0("mbedtls_tls_recv_timeout :: timed out\n");
- return( MBEDTLS_ERR_SSL_TIMEOUT );
- }
- if( ret < 0 )
- {
- #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
- !defined(EFI32)
- if( WSAGetLastError() == WSAEINTR )
- return( MBEDTLS_ERR_SSL_WANT_READ );
- #else
- if( errno == EINTR )
- return( MBEDTLS_ERR_SSL_WANT_READ );
- #endif
- return( MBEDTLS_ERR_NET_RECV_FAILED );
- }
- /* This call will not block */
- return( mbedtls_tls_recv( ctx, buf, len ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement