Altera_Forum
Honored Contributor
20 years agoLWIP 0.7.1 udp server
Hello @ all!
I want to implement a simple UDP server with the NIOS2 and LWIP 0.7.1. But there are many problems coding that simple thing. I used some predefined code (found in other newsgroup):char smdrBuff; //Buffer containing ASCII string to send via UDP.
char* ptr8;
char* buffPtr; //Ptr to allocated buffer.
struct ip_addr udpDestIpAddr; //IP addr to send UDP pkt to.
struct pbuf* pbuf1; //pbuf ptr.
struct udp_pcb* udpSkt; //UDP socket.
int i = 1;
sprintf(smdrBuff,"This is a test string!!\r\n"); //Msg to send via UDP.
//S E N D U D P M S G.
buffPtr = mem_malloc(100); //Allocate buff for UDP pkt.
memcpy(buffPtr,smdrBuff,50);
pbuf1 = pbuf_alloc(PBUF_RAW,100,PBUF_RAM); //Get a pbuf struct.
pbuf1->payload = (void*) buffPtr; //Set ptr to UDP msg.
udpSkt = udp_new(); //Get a UDP socket.
ptr8 = (char*) &udpDestIpAddr;
*ptr8 = 0xc0; //Send UDP pkts to 192.168.1.1 (smv PC).
*(ptr8+1) = 0xa8;
*(ptr8+2) = 0x01;
*(ptr8+3) = 0x01;
udp_connect(udpSkt,&udpDestIpAddr,1000); //Set-up socket with dest IP and port.
while (i<10) {
udp_send(udpSkt,pbuf1);
printf("UDP send...\n");
i++; //Send the UDP msg.
} This example runs but with (imo) crazy behaviour...with a packet sniffer i checked the incomming packages and the result is the NIOS sends 10 times ARP requests and the PC responds with the MAC. But the BUFFER is only send once. does anyone have a running UDP server ?? My goal is to send an image (from ram) permanently to the remote computer.