lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] how to send udp messages circularly ?


From: the_gadfly
Subject: [lwip-users] how to send udp messages circularly ?
Date: Fri, 3 Jul 2009 03:44:49 -0700 (PDT)

hi :
I am a newbie to nios and i want to use stand-alone lwip stack to transport
data form my board (stratix ii ) to PC.
My design is modified from a stand-alone lwip example lwip-web server. 
When the code sent data ( a string) 20 times ,only one udp message appeared
in Ethereal. And ,when the code sent two different strings in the loop ,
still one udp message appeared in Ethereal,but, the content is the last
sting.
Here is my code ,could anyone tell me what's wrong?
Best of Regards
the_gadfly 
ps: apologize for  my phraseological or other mistakes .
-------------------------------------------------------------------------
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "httpd.h"
#include "lwip/udp.h"
#include <stdio.h>
#include "sys/alt_timestamp.h"
#include "alt_types.h"

const static char Test[]="hello world !\n";
const static char Test1[]="I hope it successed!\n";

int count=0;
void Delay(unsigned long ulVal)
{
while ( --ulVal != 0 );
}
void
httpd_init(void)
{
struct udp_pcb *pcb;
struct ip_addr PCipaddr;
struct pbuf *p,*pbuffer;
err_t err;

IP4_ADDR(&PCipaddr,10,1,1,52);

p = pbuf_alloc(PBUF_RAW,sizeof(Test),PBUF_RAM);
p->payload=(void *)Test;
pbuffer = pbuf_alloc(PBUF_RAW,sizeof(Test1),PBUF_RAM);
pbuffer->payload=(void *)Test1;



pcb = udp_new();
err=udp_bind(pcb, IP_ADDR_ANY,60000);
if(err==ERR_OK)
{printf("bound ok ! \n");}
err=udp_connect(pcb,&PCipaddr,60000);
if(err==ERR_OK)
{printf("connect ok !\n");}
while( count++ < 2 ) 
{


err=udp_send(pcb,p);
if(err==ERR_OK)
{ printf("udp_send OK \n"); }
//Delay(1000000);
// Delay(1000000);
// Delay(1000000);
// err=udp_send(pcb,pbuffer);

}

} 
-- 
View this message in context: 
http://www.nabble.com/how-to-send-udp-messages-circularly---tp24321123p24321123.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]