Skip to content

Instantly share code, notes, and snippets.

@iwanbk
Created November 28, 2011 09:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwanbk/1399729 to your computer and use it in GitHub Desktop.
Save iwanbk/1399729 to your computer and use it in GitHub Desktop.
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);
}
Copy link

ghost commented Apr 5, 2017

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

@jenny13
Copy link

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