void tcp_x_init(void){ WriteToSCI1("Initializing TCP server application. \r\n"); tcp_soch = tcp_getsocket(TCP_TYPE_CLIENT, TCP_TOS_NORMAL, TCP_DEF_TOUT, tcp_control_panel_eventlistener); if( tcp_soch < 0 ) { WriteToSCI1("TCP server unable to get socket. Resetting!!!\r\n"); RESET_SYSTEM(); }else{ WriteToSCI1("TCP Get Socket Client Type!!!\r\n"); } (void)tcp_connect(tcp_soch,0xC0A800C7,2002,TCP_PORT+2);}
INT32 tcp_control_panel_eventlistener(INT8 cbhandle, UINT8 event, UINT32 par1, UINT32 par2){INT32 i;par2++; // to avoid the compiler warning if( cbhandle != tcp_soch) /* Not our handle */ return(-1); switch( event ) { case TCP_EVENT_CONREQ: WriteToSCI1("TCP: Connection request arrived!\r\n"); return(1); break; case TCP_EVENT_ABORT: WriteToSCI1("Connection aborting!\r\n"); break; case TCP_EVENT_CONNECTED: WriteToSCI1("TCP: TCP connection established!\r\n"); break; case TCP_EVENT_CLOSE: WriteToSCI1("TCP Connection closing...!\r\n"); break; case TCP_EVENT_ACK: WriteToSCI1("TCP: Data acknowledged!\r\n"); break; case TCP_EVENT_DATA: WriteToSCI1("TCP: Data arrived!\r\n"); if(par1 <= 0) break; for(i=0;i<par1;i++) { TCP_In_Msg[i]=RECEIVE_NETWORK_B(); } WriteToSCI1("Get data from server : "); WriteToSCI1(TCP_In_Msg); WriteToSCI1("\r\n"); send_ack_data(); tcp_send_buffer(); break; case TCP_EVENT_REGENERATE: tcp_send_buffer(); break; default: return(-1); }}
Hello,
OpenTCP differs from other TCP stacks that it drops connections if there's no activity.
Normally, this task should be assigned to the application, not the transport layer.
If you want to get rid of that unusual behaviour, you can modify OpenTCP or send keep-alive packets (packets with no data).
Hi,
There is a tcp timeout defined in tcp_ip.h ......
/** \def TCP_DEF_TOUT
* \ingroup opentcp_config
* \brief Default idle timeout
*
* This period defines idle timeout in seconds - this feature allows
* TCP/IP stack to close the TCP connection if no data has been exchanged
* over it during this period of time. This relates ONLY to data. Empty
* keep-alive TCP packets are not included.
*/
#define TCP_DEF_TOUT 120 //two min.
Karl