Here, I have uploaded an example of a libcoap based server for the riot os https://github.com/nikosft/libcoap/tree/master/riot I have successfully tested with the native port. Some comments
* The libcoap version included in riot is quit old (almost 3 years old; it uses a commit from 5 Feb. 2014) * Most libcoap examples I have seen use the "select (file descriptor)" command to read from a socket. This command behaves strangely in riot, that's why I am not using it. * libcoap sets the "SO_REUSEADDR" option to the listening socket. It seems that riot generates an error for that. To verify that it is not a libcoap problem I added the following three lines at riot/examples/posix_sockets/ after line 46 and it outputs "Error setting option"
int on = 1; if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) puts("Error setting option");