cancel
Showing results for 
Search instead for 
Did you mean: 

How send answer on UDP server ?

Peko
Associate III

Hello,

I created UDP server with LwIP stack on STM32F407.

I tried example udp_echo _server. It works.

Now I need send from server my own answer data in callback function.

The program hangs in callback function.

void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
	unsigned char buffer[80] = "my name is xxxxxxx";
	
	p = pbuf_alloc(PBUF_TRANSPORT,100, PBUF_RAM);
	p->payload = buffer;
        p->len = p->tot_len = 20;
 
	/* Connect to the remote client */
	udp_connect(upcb, addr, UDP_CLIENT_PORT);
 
	/* Tell the client that we have accepted it */
	udp_send(upcb, p);
 
       /* free the UDP connection, so we can accept new clients */
       udp_disconnect(upcb);
 
       /* Free the p buffer */
       pbuf_free(p);
  }

What is wrong ?

Is somewhere on web LwIP stack guide?

Thank you

0 REPLIES 0