mirror of https://github.com/wolfSSL/wolfssl.git
EmbedReceiveFrom: fix when using a TCP socket
- recvfrom() returns 0 on a closed TCP socket - TCP sockets set WOLFSSL_CBIO_ERR_ISR on a timeoutpull/5427/head
parent
da422eb422
commit
67d518544b
14
src/wolfio.c
14
src/wolfio.c
|
@ -481,6 +481,20 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||||
}
|
}
|
||||||
return recvd;
|
return recvd;
|
||||||
}
|
}
|
||||||
|
else if (recvd == 0) {
|
||||||
|
int type;
|
||||||
|
XSOCKLENT length = sizeof(int); /* optvalue 'type' is of size int */
|
||||||
|
|
||||||
|
if (getsockopt(sd, SOL_SOCKET, SO_TYPE, &type, &length) == 0 &&
|
||||||
|
type != SOCK_DGRAM) {
|
||||||
|
/* Closed TCP connection */
|
||||||
|
recvd = WOLFSSL_CBIO_ERR_CONN_CLOSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WOLFSSL_MSG("Ignoring 0-length datagram");
|
||||||
|
}
|
||||||
|
return recvd;
|
||||||
|
}
|
||||||
else if (dtlsCtx->connected) {
|
else if (dtlsCtx->connected) {
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue