--- Quote Start ---
originally posted by slacker@Nov 8 2005, 12:49 PM
danny,
at least, initially, it makes sense to model your code after the example shipped with standalone lwip. in other words, get the example working, understand what it's doing, and then add something like the following to it (in the ./apps subdirectory):
#include "echo_udp.h"# include "lwip/debug.h"# include "lwip/stats.h"# include "lwip/udp.h"# include "system.h"# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "stdlib.h"# include "stdio.h"# include "ctype.h"# include <unistd.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 );
}
echo_udp_init() initializes a new pcb, binds to local port 8, and then registers echo_udp_recv() as the callback when anything is received on port 8.
keep in mind that udp is connectionless and we're not talking about sockets, at all, with stand alone lwip. it's a totally separate distribution, available from this website.
in any case, the above code works, if you can get the example shipped with the stand alone distribution working...
cheers,
- slacker
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=10856)</div> --- Quote End ---
Hi all,
I already got the example code working. I can also send messages thanks to Revolt.... The problem now is that when I try to send a message, the only problem that I've got now is that when I send a message to a PC, it will send from source port 0 to destination port 0. Probably something I forgot to set. I am going to look at the LWIP code. Perhaps I can find a solution for my problem. The problem is that I'm an interm and at the end of january they want me to fix a couple of things. Butt as a n00b, that is not going to succeed, so I am trying to fix as much as possible, so thanx for your help all...
Cheers,
Danny