Stopping TCP server correct way

FrenkR
Posts: 44
Joined: Thu Dec 04, 2014 9:25 am

Stopping TCP server correct way

Postby FrenkR » Sun Jul 10, 2016 2:26 am

after implementing tcp listener using espconn_accept() function, client can access ESP as TCP server. I am trying to stop listener in a following way:

Code: Select all

   _iRes = espconn_get_connection_info(&httpdSvr, &_clientConn, 0);
   if (_iRes == ESPCONN_OK){
      // disconnect all
      int _i;
      for (_i = httpdSvr.link_cnt -1; _i >= 0; _i--){
         memcpy(httpdSvr.proto.tcp->remote_ip, _clientConn[_i].remote_ip, 4);
         httpdSvr.proto.tcp->remote_port = _clientConn[_i].remote_port;
         _iRes = espconn_abort(&httpdSvr);  // abort called instead "espconn_disconnect" to force disconnect socket
      }
      _iRes = espconn_delete(&httpdSvr);
      if (_iRes != ESPCONN_OK){
         if (_iRes == ESPCONN_INPROGRESS) //
           os_printf("TCP server connection in progress");
   }


problem here is that on "espconn_delete()" I am getting error ESPCONN_INPROGRESS. Is there any way to "force" stop listening and to disable TCP server?

Rgds,
Frenk

Who is online

Users browsing this forum: No registered users and 15 guests