This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

getaddrinfo positive error code + zsock_gai_strerror not available at link

Hi,

On the latest nrfConnect SDK and zephyr, I started my application based on MQTT and AWS_FOTA samples.

The BSD socket function zsock_getaddrinfo sometimes returns a positive error code (60) which I don't understand, since error codes are negative in the defines.

Additionally, the zsock_gai_strerror function is not available at link time, so I'm wondering about the configuration and compilation process involved.
The function is present in the headers and zephyr source code, but during link the compiler throws an undefined reference error.

I have the relevant configuration switch enabled:

CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_BSD_LIBRARY=y

What could be happening?

Thanks,

Julien

Parents
  • Hello Julien, 

    I started my application based on MQTT and AWS_FOTA samples.

    I presume you are using the MQTT_SIMPLE sample and the AWS_FOTA sample under nrf\samples\nrf9160 ? Have you combined these? Have you tried these samples one by one, to ensure they work as intended on your board?

    The BSD socket function zsock_getaddrinfo sometimes returns a positive error code (60) which I don't understand, since error codes are negative in the defines.

     First of all, there are two BSD libraries available: Zephyr BSD Socket part of the Zephyr project and nRF BSD Library part of the nrfxlib. The latter is used within samples provided in nrf\samples\nrf9160, and we recommend using these samples with the nRF9160 DK.

    Error codes are given in errno.h (zephyr\lib\libc\minimal\include\errno.h). The <errno.h> header file defines the integer variable errno, which is set by system calls and some library functions in the event of an error to indicate what went wrong. In the nrf samples, the nrfxlib is used and the error codes are described as followed in nRF BSD Socket API Documentation: 

    Positive number less than or equal to nfds indicating sockets on which events occurred. 0 indicates the timed out occurred and no file descriptors were ready. -1 on error, and errno indicates the reason for failure.

    In your case, error code number 60:

    From errno.h
    #define ETIMEDOUT 60    /* Connection timed out */

     Can you give more information when your code returns this error code? 

    Additionally, the zsock_gai_strerror function is not available at link time, so I'm wondering about the configuration and compilation process involved.
    The function is present in the headers and zephyr source code, but during link the compiler throws an undefined reference error.

    Difficult to say without knowing what you have done. Can you provide your code? Or give a more detailed description of what you have done so far?

    I have the relevant configuration switch enabled:

    CONFIG_NET_SOCKETS - Provide BSD Sockets like API on top of native Zephyr networking API

    CONFIG_NET_SOCKETS_POSIX_NAMES - BSD Sockets compatible API (zsock_*)

    CONFIG_BSD_LIBRARY - Configures the BSD Library for nRF91

    From what I can see, this is correct for your projects. You can also compare the prj.conf of the MQTT_Simple and the AWS_FOTA samples.

    Let me know what you are trying to do, and I will be able to help you more.

    Thanks!

    Kind regards,
    Øyvind

      

Reply
  • Hello Julien, 

    I started my application based on MQTT and AWS_FOTA samples.

    I presume you are using the MQTT_SIMPLE sample and the AWS_FOTA sample under nrf\samples\nrf9160 ? Have you combined these? Have you tried these samples one by one, to ensure they work as intended on your board?

    The BSD socket function zsock_getaddrinfo sometimes returns a positive error code (60) which I don't understand, since error codes are negative in the defines.

     First of all, there are two BSD libraries available: Zephyr BSD Socket part of the Zephyr project and nRF BSD Library part of the nrfxlib. The latter is used within samples provided in nrf\samples\nrf9160, and we recommend using these samples with the nRF9160 DK.

    Error codes are given in errno.h (zephyr\lib\libc\minimal\include\errno.h). The <errno.h> header file defines the integer variable errno, which is set by system calls and some library functions in the event of an error to indicate what went wrong. In the nrf samples, the nrfxlib is used and the error codes are described as followed in nRF BSD Socket API Documentation: 

    Positive number less than or equal to nfds indicating sockets on which events occurred. 0 indicates the timed out occurred and no file descriptors were ready. -1 on error, and errno indicates the reason for failure.

    In your case, error code number 60:

    From errno.h
    #define ETIMEDOUT 60    /* Connection timed out */

     Can you give more information when your code returns this error code? 

    Additionally, the zsock_gai_strerror function is not available at link time, so I'm wondering about the configuration and compilation process involved.
    The function is present in the headers and zephyr source code, but during link the compiler throws an undefined reference error.

    Difficult to say without knowing what you have done. Can you provide your code? Or give a more detailed description of what you have done so far?

    I have the relevant configuration switch enabled:

    CONFIG_NET_SOCKETS - Provide BSD Sockets like API on top of native Zephyr networking API

    CONFIG_NET_SOCKETS_POSIX_NAMES - BSD Sockets compatible API (zsock_*)

    CONFIG_BSD_LIBRARY - Configures the BSD Library for nRF91

    From what I can see, this is correct for your projects. You can also compare the prj.conf of the MQTT_Simple and the AWS_FOTA samples.

    Let me know what you are trying to do, and I will be able to help you more.

    Thanks!

    Kind regards,
    Øyvind

      

Children
No Data
Related