Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

won't able to read on UDP "recvfrom"

Altera_Forum
Honored Contributor II
1,663 Views

Dear friend  

i am trying to read an ethernet port using UDP (Code below),  

first read operation sucessfully return the read value (which is no of packet to be read) as soon as i enter in to do while loop it will return only one packet read ...and won't go for second read ...! 

it won't repeat the loop again....! 

 

please suggest me wher is the problem 

where 

#define MaxPkt = 1024; 

 

len = sizeof(Servaddress);  

retcode = recvfrom(sockid,PktCount1,sizeof(PktCount1),0,(struct sockaddr *) &Servaddress, &len);  

if (retcode >0)  

printf("\nClient: No. of Packet to be received is: %.d\n\n",PktCount1[0]); 

// it will display "No. of Packet to be received is: 7" 

do  

{  

LocalPktCount++; 

retcode = recvfrom(sockid,ImgBuff[1],sizeof(ImgBuff[1]),0,(struct sockaddr *) &Servaddress, &len); 

 

if(retcode <= 0) { break; printf("recv call failed"); }  

else printf("\n Packet No. received %d\n", LocalPktCount); 

 

Count = 0; // Initilize data address.....  

do  

{  

printf("%c",ImgBuff[1][Count]);  

Count++;  

}while(Count != MaxPkt);  

 

}while(LocalPktCount != PktCount1[0]+1);
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
718 Views

In your error checking, you break from the loop before printing the error message. Do it the other way round and see if you get any error message: 

if(retcode <= 0) { printf("recv call failed"); break;}
0 Kudos
Altera_Forum
Honored Contributor II
718 Views

no , there is no error message...but still it display only first packet..not second onward. 

1. can we re-use the ImgBuff[][] again and again for data writing on same location like ImgBuff[0][1448] ...? 

like first i receive the data and write in ImgBuff[0][1448] and then process it and display received data using printf then again receive the new data on same location ImgBuff[0][1448] and again process it display it and again follow the same procedure. 

2. when we create variable like ImgBuff[0][1448] , where it gose i mean where it create (SDRAM,Nios data Cache, etc), because as i increase the buffer size it won't even display the first received packet. 

3. for printing the received data can we use the same variable (ImgBuff[0][1448] ) in which we received the data, or first we copy it in some other variable for printing/display/processing etc. 

4. is printf function affect the received performance..? or due to less priority it won't affect. 

5. Is it possible that printf function skip printing data due to less priority compare to function recvfrom. 

6. Is it possiable to design client/server application without using uc/OS-ii or any other OS. ?
0 Kudos
Altera_Forum
Honored Contributor II
718 Views

ImgBuff[0][1448] occupies no memory space. 

0 Kudos
Reply