New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfml2 network should use getaddrinfo instead of gethostbyname #47

Closed
etam opened this Issue May 16, 2011 · 1 comment

Comments

Projects
None yet
2 participants
@etam

etam commented May 16, 2011

Gethostbyname is obsolete. Getaddrinfo should be used.

  1. It's written in http://kernel.org/doc/man-pages/online/pages/man3/gethostbyname.3.html
  2. Packaging sfml2 on openSUSE gives warning:
    libsfml2-2_0.x86_64: I: binary-or-shlib-calls-gethostbyname /usr/lib64/libsfml-network.so.2.0
    The binary calls gethostbyname(). Please port the code to use getaddrinfo().

@ghost ghost assigned LaurentGomila May 17, 2011

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila May 17, 2011

Member

Thanks for your feedback.

This update will also be a good starting point for a new implementation that is able to handle multiple network interfaces on the same machine.

Here is a piece of code that I can reuse later:

    addrinfo hints;
    std::memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;

    addrinfo* result = NULL;
    if (getaddrinfo("... host name ...", NULL, &hints, &result) == 0)
    {
        while (result)
        {
            sockaddr_in* addr = reinterpret_cast<sockaddr_in*>(result->ai_addr);
            Uint32 address = addr->sin_addr.s_addr;
            result = result->ai_next;
        }
        freeaddrinfo(result);
    }
Member

LaurentGomila commented May 17, 2011

Thanks for your feedback.

This update will also be a good starting point for a new implementation that is able to handle multiple network interfaces on the same machine.

Here is a piece of code that I can reuse later:

    addrinfo hints;
    std::memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;

    addrinfo* result = NULL;
    if (getaddrinfo("... host name ...", NULL, &hints, &result) == 0)
    {
        while (result)
        {
            sockaddr_in* addr = reinterpret_cast<sockaddr_in*>(result->ai_addr);
            Uint32 address = addr->sin_addr.s_addr;
            result = result->ai_next;
        }
        freeaddrinfo(result);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment