Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Not applicable
Hi there,

In the last few weeks i`ve tried to understand the procedure of the ETH04 App and to communicate via UDP. I`m still having problems to understand the difference between UDP und TCP. It would be useful to have the same APP realized in TCP.
Perhaps someone can show me how this realisation looks like?

Best regards

Here`s the code from the ETH04 APP:

#include //Declarations from DAVE3 Code Generation (includes SFR declaration)

/*Local port waiting for packets*/
#define LOCAL_PORT_RECEIVE (45555)
/*Local port used to echo back the packet*/
#define LOCAL_PORT_TRANSMIT (45174)
/*Destination port of echoed packet*/

struct udp_pcb * udp_init_comm(unsigned int port) {
/* start the UDP server */
struct udp_pcb *pcb;
/* create new UDP PCB structure */
pcb = udp_new();
udp_bind(pcb, IP_ADDR_ANY, port);
return pcb;


void udp_receive_handler (void * arg, struct udp_pcb * upcb, struct pbuf * p, struct ip_addr * addr, u16_t port)
struct pbuf * p_out;
//As handler argument is expected the pcb that shall be used for send back the data
// Allocate a buffer to store data to be transmitted
p_out = pbuf_alloc(PBUF_TRANSPORT,p->tot_len,PBUF_RAM);
//Copy received data to transmit buffer
//Send back data to same ip that sent the data but on different port
udp_sendto((struct udp_pcb *)arg,p_out,addr,TRANSMIT_PORT_DESTINATION);
//Free allocated buffer including the buffer of received data


int main(void)
struct udp_pcb *pcb_tr; //lwip pcb struct binded to transmit port
struct udp_pcb *pcb_rec; //lwip pcb struct binded to receive port

DAVE_Init(); // Initialization of DAVE Apps
lwIPStack_init(); //Start Lwip stack


//Register an handler on receive packet event


return 0;
0 Replies