Altera_Forum
Honored Contributor
17 years agoproblems receiving UDP packets
I have developped an application that is running in the host to send and receive UDP packets to my Cyclone III evaluation NIOSII board.
The transmision of the packets from my FPGA board are working but I don't have received yet any data from host. The project running in FPGA is based on the NIOSII example called simple sockets server void SSSSimpleSocketServerTask() { struct sockaddr_in serverAddr; int udpsock, status=0, bytes_sent=0, Init_img=0, Data_Length_Packet=0; alt_u8 buf[MAX_UDP_LENGHT], id_packet=0; alt_u8 *data_pointer = buf; alt_u8 *img_pointer = img_buffer; int fromlen; //----------- configuracion del socket -------------- serverAddr.sin_family = AF_INET; serverAddr.sin_port = htons (SSS_PORT); serverAddr.sin_addr.s_addr = INADDR_ANY; fromlen = sizeof (serverAddr); if ((udpsock = socket (AF_INET, SOCK_DGRAM, 0)) < 0) { // protocol <IPPROTO_UDP> alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] Socket creation failed"); } //----------- inicio del sistema -------------- IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xff); data_pointer += 4; //apunta al campo de datos del buffer a transmitir img_pointer = img_buffer; //posicion inicial de imagen //---------------------------------------------- //------------- bucle principal --------------- //---------------------------------------------- while(1){ printf("listening to UDP port...\n"); status = recvfrom(udpsock, buf, 10, 0,(struct sockaddr*)&serverAddr, &fromlen); if (status == -1){ alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] Rx UDP error"); id_packet = 0; bytes_sent = 0; } After recvfrom() this application is always locked waiting incoming packets although I have sent some packets from the host computer.