I have a server and client connected though wifi.
server receive code:
int32_t recv_len = 0;
char errbuffer[WOLFSSL_MAX_ERROR_SZ];
unsigned int err;
unsigned int rc = 0;
do
{
recv_len = wolfSSL_recv(ssl, buffer, length, flags);
Tr_Wrn("wolfSSL_read->recv_len:%d", recv_len);
if (recv_len < 0)
{
err = wolfSSL_get_error(ssl, 0);
Tr_Err("err = %d, %s\n", err, wolfSSL_ERR_error_string(err, errbuffer));
if ((err == SSL_ERROR_WANT_READ) || (err == SSL_ERROR_WANT_WRITE))
{
Tr_Wrn("err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE");
}
else
{
return -1;
}
}
else if (recv_len == 0 )
{
Tr_Wrn("peer socket closed!!!");
return 0;
}
else
{
rc += recv_len;
buffer += recv_len;
}
} while((recv_len < 0) && ((err == SSL_ERROR_WANT_READ) || (err == SSL_ERROR_WANT_WRITE)));
The flags is set MSG_DONTWAIT. When server is receiving a big data from client, the wifi is broken suddenly.
Print log is:
viwi: 26037048-[viwi soc]-W-00:13:23.800-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037049-[viwi soc]-E-00:13:23.800-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037050-[viwi soc]-W-00:13:23.800-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037051-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037052-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037053-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037054-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037055-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037056-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037057-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037058-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037059-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037060-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037061-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037062-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037063-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037064-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037065-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037066-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037067-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037068-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037069-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037070-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037071-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037072-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037073-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037074-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037075-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037076-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037077-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
viwi: 26037078-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-79-wolfSSL_read->recv_len:-1
viwi: 26037079-[viwi soc]-E-00:13:23.801-SSLSocket.cpp-83-err = 2, non-blocking socket wants data to be read
viwi: 26037080-[viwi soc]-W-00:13:23.801-SSLSocket.cpp-86-err SSL_ERROR_WANT_READ / SSL_ERROR_WANT_WRITE
And will not stop printing this log.
So I want to know how can i know the connecting is broken and stop receiving.