Wikia

lwIP Wiki

Raw/UDP

Talk0
89pages on
this wiki
struct udp_pcb * udp_new(void)

Creates a new UDP pcb which can be used for UDP communication. The pcb is not active until it has either been bound to a local address or connected to a remote address.

void udp_remove(struct udp_pcb * pcb)

Removes and deallocates the pcb.

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

Binds the pcb to a local address. The IP-address argument "ipaddr" can be IP_ADDR_ANY to indicate that it should listen to any local IP address. The function returns ERR_USE if the specified port is already in use, otherwise ERR_OK.

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 unconected pcbs receive datagrams from any remote address.

void udp_disconnect(struct udp_pcb * pcb)

Remove the remote end of the pcb. This function does not generate any network traffic, but only removes the remote address of the pcb.

err_t udp_send(struct udp_pcb * pcb, struct pbuf * p)

Sends the pbuf p to the remote address set using udp_connect(). The pbuf is not deallocated.

err_t udp_sendto(struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port);

Same as udp_send(), but sends to any remote address.

void udp_recv(struct udp_pcb * pcb,
               void (* recv)(void * arg, struct udp_pcb * upcb,
                                         struct pbuf * p,
                                         struct ip_addr * addr,
                                         u16_t port),
               void * recv_arg)

Specifies a callback function that should be called when a UDP datagram is received on the specified connection. The callback function is responsible for deallocating the pbuf.

Advertisement | Your ad here

Around Wikia's network

Random Wiki