Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket.c listen() bug #127

Open
DmitryGostev opened this issue Nov 10, 2022 · 1 comment
Open

socket.c listen() bug #127

DmitryGostev opened this issue Nov 10, 2022 · 1 comment

Comments

@DmitryGostev
Copy link

The bug occurs when the client connects instantly after listen(), getSn_SR(sn) never returns SOCK_LISTEN, but returns SOCK_ESTABLISHED. In this case listen() calls close(sn) and returns SOCKERR_SOCKCLOSED.

Possible fix:
socket.c, int8_t listen(uint8_t sn)
changing code

while(getSn_SR(sn) != SOCK_LISTEN)
{
close(sn);
return SOCKERR_SOCKCLOSED;
}

to

==============================
uint8_t res;

.....

res=getSn_SR(sn);
if (res != SOCK_LISTEN && res!=SOCK_ESTABLISHED)
{
close(sn);
return SOCKERR_SOCKCLOSED;
}

@irinakim12
Copy link
Contributor

irinakim12 commented Nov 20, 2023

The situation you describe, where there might be a delay between calling listen() and checking the socket status using getSn_SR before a TCP connection is established, seems plausible. Although it may not be a common occurrence, we will discuss it internally before deciding to implement it.

Listen() Function
image

Serial output

image

irinakim12 added a commit to irinakim12/ioLibrary_Driver that referenced this issue Nov 20, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants