I tried this code:
SocketAddress sockAddr;
connect_status = NSAPI_ERROR_OK;
int index = 0;
while(connect_status == NSAPI_ERROR_OK) {
connect_status = network->get_dns_server(index++, &sockAddr, "st0");
if ((connect_status == NSAPI_ERROR_OK) || (index == 1)) {
switch (sockAddr.get_ip_version()) {
case NSAPI_IPv4: printf("[NWKH] DNS #%d IPv4: ", index); break;
case NSAPI_IPv6: printf("[NWKH] DNS #%d IPv6: ", index); break;
default: printf ("[NWKH] DNS #%d IPv unknown: ", index);
}
(connect_status == NSAPI_ERROR_OK) ? printf(" %s:%d\n", sockAddr.get_ip_address(), sockAddr.get_port()) : printf("get DNS err: %d\n", connect_status);
}
}
And sockAddr.get_port()
is always 0
. Can someone confirm this? Shouldn’t this be the typical DNS port 53
?
My problem still is that line 62
of mbed-http - Fork of SandBox’s original mbed-http (https://os… | Mbed fails with error -3009
. Any ideas where to start debugging?
Edit:
I changed NetworkInterface::gethostbyname
to this:
nsapi_error_t NetworkInterface::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version, const char *interface_name)
{
printf("STACK NAME: %s\r\n", typeid(get_stack()).name());
return get_stack()->gethostbyname(name, address, version, interface_name);
}
with the result P12NetworkStack
. After grep
-ing for this name I only get entries in .map
-files so it looks to me like this is some kind of binary-blob which is linked at compile time? But where is the source-code?
Can I switch the network-stack?
Edit: Okay, I think I found the solution thanks to this post: Gethostbyname() question - Mbed OS - Arm Mbed OS support forum
network->gethostbyname(_parsed_url->host(), &address, NSAPI_IPv4, "st0");
Notice the two additional parameters at the end.