Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
758 Views

Modifying SSS example to use SOCK_DGRAM

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
52 Views

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

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