2023-08-08 06:24 AM
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
Solved! Go to Solution.
2023-08-10 08:22 AM
In both my PTP sources and the UDP echo test I use udp_sendto.
2023-08-08 07:33 AM
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! ;)
2023-08-08 08:46 AM
Thanks. I'd read the documentation. I was really looking for some information explained differently from a different source.
2023-08-09 04:49 AM
Okay, it's basically all in there.
2023-08-09 05:22 AM - edited 2023-08-09 05:22 AM
@LCE which function do you normally use?
2023-08-10 08:22 AM
In both my PTP sources and the UDP echo test I use udp_sendto.