Hi Dominik, Kirean, list...
here is an updated version of my little example UDP echo server. It uses
now udp_sendto(), which I totally overlooked the first time...
It would be nice if you could include this in the rawapi.txt or some
other documentation file distributed with the source (and of course:
more documentation on the website, please).
Cheers,
Juri
#include "lwip/udp.h"
#include "lwip/debug.h"
void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
if (p != NULL) {
/* send received packet back to sender */
udp_sendto(pcb, p, addr, port);
/* free the pbuf */
pbuf_free(p);
}
}
void udp_echo_init(void)
{
struct udp_pcb * pcb;
/* get new pcb */
pcb = udp_new();
if (pcb == NULL) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));
return;
}
/* bind to any IP address on port 7 */
if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));
return;
}
/* set udp_echo_recv() as callback function
for received packets */
udp_recv(pcb, udp_echo_recv, NULL);
}
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users