CReal,
We're not talking about sockets, with the "raw" api and, according to the documentation, udp_connect() does not generate any network traffic.
At a minimum, I suggest that you read the rawapi.txt file, where this function is described.
Here's a quick code example, which should work, as well. It sets up an "echo" server on port 8.
#include "echo_udp.h"# include "lwip/debug.h"# include "lwip/stats.h"# include "lwip/udp.h"
static void
echo_udp_recv( void* arg, struct udp_pcb *pcb,
struct pbuf *p,
struct ip_addr *addr,
u16_t port )
{
err_t err;
err = udp_connect( pcb, addr, port );
if (err != ERR_OK)
{
printf( "ERROR: udp_connect() error: %d\n", err );
}
err = udp_send( pcb, p );
if (err != ERR_OK)
{
printf( "ERROR: udp_send() error: %d\n", err );
}
pbuf_free( p );
udp_remove( pcb );
echo_udp_init();
return;
}
void
echo_udp_init(void)
{
struct udp_pcb *pcb;
pcb = udp_new();
udp_bind( pcb, IP_ADDR_ANY, 8 );
udp_recv( pcb, echo_udp_recv, NULL );
}
You would have to declare the echo_udp_init() prototype in echo_udp.h and then call this function from within main(), to get things started. Just take a look at the webserver example, shipped with stand alone LWIP, and you'll see what I mean.
- slacker