Skip to main content
Graduate II
August 8, 2023
Solved

LWIP Raw API udp_send() Cube MX HAL

  • August 8, 2023
  • 4 replies
  • 2948 views

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

    This topic has been closed for replies.
    Best answer by LCE

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

    4 replies

    Graduate II
    August 8, 2023

    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! ;)

    ######Author
    Graduate II
    August 8, 2023

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

    Graduate II
    August 9, 2023

    Okay, it's basically all in there.

    ######Author
    Graduate II
    August 9, 2023

    @LCE which function do you normally use?

    LCEAnswer
    Graduate II
    August 10, 2023

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