This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

raw LWIP tcp server - how can I send data periodically?

I am trying to send data periodically modifying echoserver in C6748 LCDK but no idea how to do it.

please refer to below code which I implemented and correct me.

void TCPIPAPP(void)
{
struct tcp_pcb *pcb;
err_t err_APP;

char *txdata = "Hello!";
unsigned int totlen = 0;
totlen= strlen(txdata)&0x00FF;

pcb = tcp_new();
tcp_bind(pcb, IP_ADDR_ANY, ECHO_SERVER_PORT);
pcb = tcp_listen(pcb);
/* initialize callback arg and accept callback */
tcp_arg(pcb, pcb);
tcp_accept(pcb, echo_accept);

printf("%s\n", "TCP/IP connected");
printf("%s\n", "Write Hello!");
err_APP = tcp_write(pcb, txdata, totlen, TCP_WRITE_FLAG_COPY);
tcp_output(pcb);
while(1)
{
printf("%d\n", pcb->state);
if (pcb->state == ESTABLISHED )
printf("%s\n", "TCPIP Connection established");
printf("%d\n", pcb->state);
err_APP = tcp_write(pcb, txdata, totlen, TCP_WRITE_FLAG_COPY);
tcp_output(pcb);
if(err_APP!=ERR_OK)
{
while(1);
}
printf("%s\n", "Write Hello!");
printf("err_APP Value: %d /n", err_APP);
} //end of while

} //end of TCPIPAPP

In this code I created a pcb and made  tcp connection to hyper terminal. Connection was good and I could send Hello! to hyper terminal by inserting tcp_write function into echo_accept callback function. However, since I want to send data periodically and continuously, so I tried to implement send data using infinite loop as above but so far I couldn't send nothing. Even when I checked pcb' state, it stay always in linking state. So I wonder how I can access to current connected pcb and how do I control data transmit timing.