cancel
Showing results for 
Search instead for 
Did you mean: 

How can I send data over TCP / LwIp?

DCtech
Associate II

I am using Echoserver and EchoClient source code for stm32. 

I used `tcp_echoserver_init();` function to start callback and I tried to connect with python client to this server. And its successfully connect. I checked with wireshark. And python program didnt give any error. 

But I want to send data from server to client, but I didnt do that. I get always `Errorr 2` ( When I connect to server from client, I didnt get any data)

I initilize the server with `tcp_echoserver_init();` again and

`tcp_data_send` function calling in while loop. How can I send data over tcp correctly ?

void tcp_data_send(void)
 {
     err_t err;
 
 char data1[] = { 1, 2, 3, 4}; 
 if( tcp_echoserver_pcb != NULL && (tcp_echoserver_pcb->state == ESTABLISHED))
 {
 /* send data1 */
 
 err = tcp_write(tcp_echoserver_pcb, (const void *)&data1, 4, 0); 
 err = tcp_output(tcp_echoserver_pcb);
 SerialPrint(" established \n");
 
 if( ( err == ERR_MEM ) )
 {
   SerialPrint("Errorr 1");
 // close_my_conn( my_pcb );
 } 
 
 }
 else
 {
     SerialPrint("Errorr 2");
 
 }  
   
}

  

1 REPLY 1
DCtech
Associate II

Is there any answer for this?