ESP8266 Developer Zone The Official ESP8266 Forum 2017-03-10T14:37:22+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=3236 2017-03-10T14:37:22+08:00 2017-03-10T14:37:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3236&p=11469#p11469 <![CDATA[Re: The TCP keep alive function seems doesn't work]]> could you tell me, Under what conditions ? TCP server automatically disconnect TCP client ;
is it a few minutes ?

Statistics: Posted by 朝花夕拾 — Fri Mar 10, 2017 2:37 pm


]]>
2017-01-09T19:06:22+08:00 2017-01-09T19:06:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3236&p=11065#p11065 <![CDATA[Re: The TCP keep alive function seems doesn't work]]> Statistics: Posted by sunweili50 — Mon Jan 09, 2017 7:06 pm


]]>
2017-01-09T19:08:44+08:00 2017-01-09T19:04:16+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3236&p=11064#p11064 <![CDATA[Re: The TCP keep alive function seems doesn't work]]>
ESP_Xutao wrote:
Hi:
You can use espconn_regist_time(0;

you mean i should replace all the POSIX functions with espconn_xxx api?
i don't think this function can used mix with the socket(), connect()....

Statistics: Posted by sunweili50 — Mon Jan 09, 2017 7:04 pm


]]>
2017-01-09T16:03:43+08:00 2017-01-09T16:03:43+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3236&p=11059#p11059 <![CDATA[Re: The TCP keep alive function seems doesn't work]]> You can use espconn_regist_time(0;

Statistics: Posted by ESP_Xutao — Mon Jan 09, 2017 4:03 pm


]]>
2017-01-06T22:49:44+08:00 2017-01-06T22:49:44+08:00 https://bbs.espressif.com:443/viewtopic.php?t=3236&p=11048#p11048 <![CDATA[The TCP keep alive function seems doesn't work]]> 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:

   ...
   client_fd= socket();
   ...
   
   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));
   
   ...
   connect(client_fd);
   ...


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 !!!

Statistics: Posted by sunweili50 — Fri Jan 06, 2017 10:49 pm


]]>