From db02f2c6dc239ed25ea1ebce40a5fa3d60f120f8 Mon Sep 17 00:00:00 2001 From: irinakim Date: Mon, 20 Nov 2023 16:52:52 +0900 Subject: [PATCH] #127 If reading Sn_SR in the Listen() function reveals that the socket is already in a connected state, issues may arise. - Resolved by adding a check for SOCK_ESTABLISHED within the section of the Listen() function where Sn_SR is examined. --- Ethernet/socket.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ethernet/socket.c b/Ethernet/socket.c index 412a65d..f351819 100644 --- a/Ethernet/socket.c +++ b/Ethernet/socket.c @@ -240,13 +240,15 @@ int8_t close(uint8_t sn) int8_t listen(uint8_t sn) { + uint8_t getSR = 0; CHECK_SOCKNUM(); CHECK_SOCKMODE(Sn_MR_TCP); CHECK_SOCKINIT(); setSn_CR(sn,Sn_CR_LISTEN); while(getSn_CR(sn)); - while(getSn_SR(sn) != SOCK_LISTEN) - { + getSR = getSn_SR(sn); + while(getSR != SOCK_LISTEN && getSR != SOCK_ESTABLISHED) + { close(sn); return SOCKERR_SOCKCLOSED; }