I am trying to run FreeCoap (https://github.com/keith-cullen/FreeCoAP) to be able to communicate with COAP and DTLS on a Intel Galileo gen. 2 board. I have seen that out of the box tests compile and run correctly (as long as I have been able to test by now).
I have seen that it is prepared to run over IPv6. I am no expert on it, but I have seen that it has the value host configured as ::1, what I understand is the localhost. When I have tried to change it to IPv4, that is 127.0.0.1 or the actual IP address of the board I am getting errors.
I have seen that it uses netdb.h to create the server.
#include <netdb.h>
...
#define HOST "127.0.0.1" /**< Host address to listen on */
#define PORT "12436"
...
unsigned char msg_id[2] = {0};
struct addrinfo hints = {0};
struct addrinfo *list = NULL;
struct addrinfo *node = NULL;
hints.ai_flags = 0;
hints.ai_family = AF_INET; /* value = 2 preferred socket domain */
hints.ai_socktype = SOCK_DGRAM; /* value = 3 preferred socket type */
hints.ai_protocol = 0; /* preferred protocol (3rd argument to socket()) - 0 specifies that any protocol will do */
hints.ai_addrlen = 0; /* must be 0 */
hints.ai_addr = NULL; /* must be NULL */
hints.ai_canonname = NULL; /* must be NULL */
hints.ai_next = NULL; /* must be NULL */
ret = getaddrinfo(HOST, PORT, &hints, &list);
As result of getaddrinfo what I get is a -16 value, indicating the following error:
Error : Device or resource busy
I have tried searchig with netstat -a
and there is no such port in use.
What I am missing? What resource is busy and not allowing me to get the address?