Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LWIP UDP Echo Server with RAW API
/*
* author : Iwan Budi Kusnanto (ibk@labhijau.net)
*/
#include "lwip/api.h"
#include "lwip/sys.h"
#include "lwip/udp.h"
#include "udpecho_raw_server.h"
static void udpecho_raw_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
{
LWIP_UNUSED_ARG(arg);
if(p == NULL)
return;
udp_sendto(pcb, p, addr, port);
pbuf_free(p);
}
/*-----------------------------------------------------------------------------------*/
void udpecho_raw_server_init(u16_t port)
{
struct udp_pcb *pcb;
printf("%s() ..........\n", __func__);
pcb = udp_new();
udp_bind(pcb, IP_ADDR_ANY, port);
/* no need to loop forever */
udp_recv(pcb , udpecho_raw_recv, pcb);
}
@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Apr 5, 2017

What is your "udpecho_raw_server.h" file... can you share it ?

@jenny13

This comment has been minimized.

Copy link

@jenny13 jenny13 commented Apr 6, 2017

hi, what is your "udpecho_raw_server.h" in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment