Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHello Dai -
I did get the linux build/hjardware you sent me a link to (the one without the LCD nios) up and running the SSS example - now I am trying to get UDP running on it. I replaced SSSSimpleSocketServer() with the following... The results is that I get nothing when sending a udp packet to the board. The code is stalled in the recvfrom and it is waiting... I am using UDP tester to send to port 1024 and verifying that it is on the wire with packetmon... Any help would be most appreciated... Thanks - Chris void ssssimplesocketservertask() { struct sockaddr_in serverAddr; int udpsock, status=0, bytes_sent=0; alt_u8 buf[MAX_UDP_LENGTH], id_packet=0; int fromlen; //----------- Socket Configuration -------------- serverAddr.sin_family = AF_INET; serverAddr.sin_port = htons(UDP_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"); } //----------- system init goes here -------------- //---------------------------------------------- //------------- Main loop for task --------------- //---------------------------------------------- while(1){ printf("listening to UDP port...\n"); printf("serverAddr.sin_family = %08x\n", serverAddr.sin_family); printf("serverAddr.sin_port =%08x\n", serverAddr.sin_port); printf("serverAddr.sin_addr.s_addr =%08x\n", serverAddr.sin_addr.s_addr); printf("serverAddr =%08x\n", serverAddr); if((recvfrom(udpsock, buf, 10, 0,(struct sockaddr*)&serverAddr, &fromlen)) <0 ) { alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE,"[sss_task] rx UDP error"); } else{ printf("we got here\n"); }   printf("datagram : %s", buf); }