i am using the socket(), connect(),close() ... functions directly instead of the espconn_xxxx() api.
when i set the keep alive parameters for a tcp client :
Code: Select all
int keepAlive = 1; //enable keepalive
int keepIdle = 10; //60s
int keepInterval = 5; //5s
int keepCount = 3; //retry times
rslt = setsockopt(client_fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepAlive, sizeof(keepAlive));
rslt = setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPIDLE, (void*)&keepIdle, sizeof(keepIdle));
rslt = setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepInterval, sizeof(keepInterval));
rslt = setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPCNT, (void *)&keepCount, sizeof(keepCount));
it seems that the setsockopt functions does't work.
when the server close the socket , the esp8266 seems does't know that in correct time.
in other words, the recv() don't return -1 in 10+5*3 = 25seconds when the server close socket. the recv() always return -1 in 2minutes.
anybody help,thanks very much !!!