cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP Raw API udp_send() Cube MX HAL

######
Senior

Hi,

LWIP: what is the difference between udp_send() and udp_sendto()?

What are the use cases for each? 

The LWIP_RAW_CLIENT ECHO uses udp_send() but also uses udp_connect. Whereas udp_sendto() does not need to connect?

Does anyone have example? 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

In both my PTP sources and the UDP echo test I use udp_sendto.

View solution in original post

5 REPLIES 5
LCE
Principal

https://lwip.fandom.com/wiki/Raw/UDP

err_t udp_connect(struct udp_pcb * pcb, struct ip_addr * ipaddr, u16_t port)

Sets the remote end of the pcb. This function does not generate any network traffic, but only set the remote address of the pcb. It binds the pcb to a local address if it is not already bound. It returns ERR_USE if no port is available, ERR_RTE if there is no route to the destination, or ERR_OK. Connecting is only needed when using udp_send(). For unconnected pcbs, udp_sendto() can be used to send to any specified remote address. Connected pcbs only receive data from the connected remote address, while unconnected pcbs receive datagrams from any remote address.

Sometimes google helps! ;)

Thanks. I'd read the documentation. I was really looking for some information explained differently from a different source.

LCE
Principal

Okay, it's basically all in there.

######
Senior

@LCE which function do you normally use?

LCE
Principal

In both my PTP sources and the UDP echo test I use udp_sendto.