return( 0 );
}
+static int mbedtls_net_errno(int fd)
+{
+ int sock_errno = 0;
+ u32_t optlen = sizeof(sock_errno);
+ getsockopt(fd, SOL_SOCKET, SO_ERROR, &sock_errno, &optlen);
+ return sock_errno;
+}
+
/*
* Initialize a context
*/
if( ( fcntl( ctx->fd, F_GETFL, 0) & O_NONBLOCK ) != O_NONBLOCK )
return( 0 );
- int error = 0;
- get_errno(ctx->fd, &error);
+ int error = mbedtls_net_errno(ctx->fd);
+
switch( error )
{
#if defined EAGAIN
int ret;
int fd = ((mbedtls_net_context *) ctx)->fd;
int error = 0;
- get_errno(fd, &error);
+
if( fd < 0 )
return( MBEDTLS_ERR_NET_INVALID_CONTEXT );
if( net_would_block( ctx ) != 0 )
return( MBEDTLS_ERR_SSL_WANT_READ );
+ error = mbedtls_net_errno(fd);
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET )
int fd = ((mbedtls_net_context *) ctx)->fd;
int error = 0;
- get_errno(fd, &error);
if( fd < 0 )
return( MBEDTLS_ERR_NET_INVALID_CONTEXT );
if( net_would_block( ctx ) != 0 )
return( MBEDTLS_ERR_SSL_WANT_WRITE );
+ error = mbedtls_net_errno(fd);
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET )