select() seems to signal data to read from a shut down socket [solved]
Posted: Sat Nov 03, 2018 3:18 am
I use select() to catch read and exception events:
This has worked fine before, recv()ing at read events and disconnecting at exception events. But now after a few months I need to build on this code for another project I have some problems.
Connections to server socket and reads from connection sockets work fine, but If I do a graceful disconnect (FIN), instead of immediately getting an exception event as before, it instead sets a read event, which fails as there is no data to recv():
This flag is never cleared and the program is in an infinite select()-recv()-select()-recv() loop for quite some while until something times out and the exception event is flagged.
Has an update broken something or is my program flawed in some way?
Code: Select all
returncount=select(max_socket,&read,NULL,&exception,NULL);
Connections to server socket and reads from connection sockets work fine, but If I do a graceful disconnect (FIN), instead of immediately getting an exception event as before, it instead sets a read event, which fails as there is no data to recv():
Code: Select all
V (268658) wifi.c: tcp_server_task(): 2 socket(s)
V (269268) wifi.c: tcp_server_task(): select (1 sockets active)
W (269268) wifi.c: tcp_server_task(): Recv returned 0! ESP_OK
Has an update broken something or is my program flawed in some way?