Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12367 Discussions

Modifying SSS example to use SOCK_DGRAM

Altera_Forum
Honored Contributor I
764 Views

I made a trivial change today to the Simple Socket Server example that comes with the altera software. I changed the SOCK_STREAM to SOCK_DGRAM. Now the listen() fails for some reason, but errno is 0?? Code and output are below. 

 

if ((fd_listen = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE," Socket creation failed"); } addr.sin_family = AF_INET; addr.sin_port = htons(30); addr.sin_addr.s_addr = INADDR_ANY; if ((bind(fd_listen,(struct sockaddr *)&addr,sizeof(addr))) < 0) { alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE," Bind failed"); } if ((listen(fd_listen,1)) < 0) { printf("errno = %d\n", errno); alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE," Listen failed"); }  

 

Created "Nios II Simple Socket Server" task (Prio: 10) 

errno = 0 

 

 

[Network]: See STDERR for expanded diagnosis translation. 

[Network]: [SSS_task] Listen failed 

[Network]: ERRNO: :  

 

 

[Network]: See STDERR (FAULT_LEVEL is SYSTEM). 

[Network]: FAULT_LEVEL is SYSTEM. 

[Network]: FATAL Error, Restart required. 

[Network]: Locking scheduler - endless loop. 

No free buffers for rx 

No free buffers for rx
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
58 Views

You cannot use listen or accept with message-oriented (=dgram) sockets. 

They makes sense only with stream sockets which are connection-oriented
Reply