SNICInterface for ThingPlug Example
Dependents: ThingPlug_WiFi_Example ThingPlug_WiFi_Example_2
Fork of SNICInterface by
Diff: Socket/TCPSocketConnection.cpp
- Revision:
- 54:cb4c105a2ad2
- Parent:
- 48:ee7e07fb401f
--- a/Socket/TCPSocketConnection.cpp Tue Mar 31 03:16:46 2015 +0000 +++ b/Socket/TCPSocketConnection.cpp Thu Aug 13 06:44:01 2015 +0000 @@ -35,7 +35,10 @@ C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance(); C_SNIC_UartCommandManager *uartCmdMgr_p = snic_core_p->getUartCommand(); + int retry_cnt=5; + FUNC_IN(); +conn_again: // Socket create ret = createSocket(); if( ret != 0 ) @@ -98,6 +101,14 @@ { DEBUG_PRINT( "connect failed\r\n" ); snic_core_p->freeCmdBuf( payload_buf_p ); + + retry_cnt--; + printf("retry_wait(%d)\r\n", retry_cnt); + if(retry_cnt>0){ + close(); + goto conn_again; + } + FUNC_OUT(); return -1; } @@ -106,6 +117,14 @@ { DEBUG_PRINT("connect status:%02x\r\n", uartCmdMgr_p->getCommandStatus()); snic_core_p->freeCmdBuf( payload_buf_p ); + + retry_cnt--; + printf("retry_status(%d)\r\n", retry_cnt); + if(retry_cnt>0){ + close(); + goto conn_again; + } + FUNC_OUT(); return -1; }