4

We are currently using Oat++ (https://oatpp.io/) as a webserver for an embedded project. It is working wonder with several environments: docker container, ubuntu VM, Raspberry Pi 3.

However, for this project we have our own linux distribution built with Yocto (https://www.yoctoproject.org/) and after some debugging, we realize that the getaddrinfo (http://man7.org/linux/man-pages/man3/getaddrinfo.3.html) function is not working.

Here's a sample code of what is happening:

struct addrinfo *result = NULL;
struct addrinfo hints;
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;

int iResult = getaddrinfo(NULL, "8080", &hints, &result);

// iResult == EAI_ADDRFAMILY

Has anyone any idea of what could be the problem?

PS: We tried comparing the kernel config with the one from the Raspberry Pi 3 but without success PSS: We also tried to set the IP (i.e.: getaddrinfo("192.168.1.10", "8080", &hints, &result)), also without success

ThmX
  • 149
  • 2
  • 6
  • are you using glibc or musl? – vermaete Jan 08 '20 at 13:20
  • Hello @ThmX, as I understand you are talking about oatpp client connection provider. At early days it was using `gethostbyname` method instead of `getaddrinfo` if it is an option for you - try to use it. I don't know if it works on Yocto but according to shreds of info on the internet it should. See prev version of client connection provider - https://github.com/oatpp/oatpp/blob/14ec8c0a4f3c72f2ed3c62beb0b9ff356b7cae3c/src/oatpp/network/client/SimpleTCPConnectionProvider.cpp#L49 – lganzzzo Jan 08 '20 at 20:41
  • Apart from double checking the actual network configuration (e.g. is it really IPv4?) the only thing I can think of here is 'hints' struct initialization: You should initialize it to zeros. – Jussi Kukkonen Jan 08 '20 at 21:46

1 Answers1

1

Well, we found that the problem was not with getaddrinfo... Sorry for that.

The problem was because of IPv6 (the implementation of SimpleTCPConnectionProvider for linux is only using INET6) and our system is built only with IPv4.

So I created my own ServerConnectionProvider that implements a socket with INET instead of INET6.

ThmX
  • 149
  • 2
  • 6