Hi all! I am LwIP beginner. I am working with project lwip_echo (StarterWare 01.20.04.01 for LCDKC6748). I redid enet_echo under UDP.
I encountered such a problem : I can not send UDP-packets to a specific ip-address. The paradox is that the example of a TCP echo server works fine. Broadcast operates on UDP, but if you prescribe a specific ip-number, the packages do not come to the client ( packets come without problems to the echo server) . I did not touch files LwIP stack (except the ip-number).
This is code of udp_echo:
void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { if (p != NULL) { //udp_connect(pcb,addr, port); udp_sendto(pcb, p, addr, port); //there are no errors pbuf_free(p); } } void udp_echo_init(void) //main function { struct udp_pcb * pcb; pcb = udp_new(); if (pcb == NULL) { LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n")); return; }
if (udp_bind(pcb, IP_ADDR_ANY, ECHO_SERVER_PORT) != ERR_OK) {//there are no errors LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n")); return; } udp_recv(pcb, udp_echo_recv, NULL); }