wiced_tcp_connect hang


#1

Hi, if I purposely stop my tcp server so the socket doesn’t connect, this app stops after the second iteration of the while loop. Am I doing something wrong?

#include "wiced.h"  
  
  
static wiced_tcp_socket_t tcp_client_socket;  
  
  
void application_start( )  
{  
  const unsigned long ip_address = MAKE_IPV4_ADDRESS(192,168,0,11);  
  const unsigned long port = 5011;  
  const wiced_ip_address_t INITIALISER_IPV4_ADDRESS(server_ip_address, ip_address);  
  
  
  wiced_init();    
  while ( 1 ) {   
    wiced_network_up(WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL);  
    wiced_result_t result;  
    result = wiced_tcp_create_socket(&tcp_client_socket, WICED_STA_INTERFACE);  
    wiced_tcp_bind(&tcp_client_socket, port);  
    wiced_tcp_connect(&tcp_client_socket, &server_ip_address, port, 2000);  
    if (result == WICED_SUCCESS) {  
      WPRINT_APP_INFO(("DISCONNECT\n"));  
      wiced_tcp_disconnect(&tcp_client_socket);  
    }  
    wiced_tcp_delete_socket(&tcp_client_socket);  
    wiced_network_down(WICED_STA_INTERFACE);  
  }  
}  

I’ve tested and get the same result using both WICED-SDK-3.3.1 & WICED-SDK-3.5.2. If I remove the wiced_tcp_connect call then the loop continues indefinitely.


#2

Hi @mdelbo, How about insert a delay between each iteration?

Cheers!


#3

Thanks for replying! I’ve tried a delay in between but it still hangs + there is a 2s connection timeout on the tcp connect. The hang occurs on the wiced_network_down call.


#4

By the way, if I start my tcp server the snippet above works fine without hanging. I don’t want my firmware to hang though if the server is unavailable.