ioLibrary_Driver
ioLibrary_Driver copied to clipboard
socket.c listen() bug
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; }
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
Serial output