Altera_Forum
Honored Contributor
15 years agowon't able to read on UDP "recvfrom"
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);