Giter Site home page Giter Site logo

Comments (7)

tdv avatar tdv commented on August 20, 2024 1

Hello. I'm really appreciated your commit. However, I need to notice one moment, the function 'from_string' can't recognize 'localhost' like an address. I have to use 'resolver' to use 'localhost' like the address instead of only '127.0.0.1' in order to overcove the problem. That is why I didn't use 'from_string' instead of 'resolver'.
Could you propose a solution with a simultaneously equivalent behavior to use 'localhost' and '127.0.0.1' like the address excluding the solution with 'resolver'?
Thank you again.

from redis-cpp.

tdv avatar tdv commented on August 20, 2024 1

I had looked at the latest 'boost' (1.73) again and noticed 'resolver.resolve' among the examples (the link below). Why did you decide the 'resolver.resolve' is deprecated?
https://www.boost.org/doc/libs/1_73_0/libs/beast/example/http/client/sync/http_client_sync.cpp

from redis-cpp.

tdv avatar tdv commented on August 20, 2024 1

Hello. From your message I noticed you used cygwin thus I decided you used Windows. I don't use Windows more than 10 year, I'm Linux user last 10 years. I can't check particularly your case. Nevertheless, I've tried to fix the problem having seen on your commit. Appealing to that I'd like to propose you trying use it with new macros. If you use header-only version, try to update the library from git and use it with a macros REDISCPP_EASY_ADDRESS_RESOLVE. Please define it before usage the library like below
#define REDISCPP_EASY_ADDRESS_RESOLVE
#include ...

Unfortunatelly, in this case you can't use something like 'localhost', only IP like '127.0.0.1' or others.

Also, report me about results of usage with a new macros, of course, if you would mind :)

Thanks for addressing me about your issue. Hopefully, my commit will fix the problem. I will be waiting for your report about usage of the changes.

from redis-cpp.

JuKu avatar JuKu commented on August 20, 2024

Maybe this solution works:

stream(const char* host, int port)
    {
        boost::asio::ip::tcp::resolver resolver{io_context_};

        //resolver.resolve() is deprecated
        /*auto endpoints = resolver.resolve(std::move(host), std::move(port));
        auto iter = std::begin(endpoints);
        if (iter == std::end(endpoints))
            throw std::runtime_error{"There is no any endpoint."};*/

        boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string(host), port);

        socket_.connect(endpoint);
        socket_.set_option(boost::asio::ip::tcp::no_delay{});

        stream_ = std::make_unique<stream_type>(socket_);
    }

from redis-cpp.

JuKu avatar JuKu commented on August 20, 2024

I have added a possible PR for this issue:
#2

from redis-cpp.

JuKu avatar JuKu commented on August 20, 2024

@tdv Thanks for your fast answer!

However, I need to notice one moment, the function 'from_string' can't recognize 'localhost' like an address. I have to use 'resolver' to use 'localhost' like the address instead of only '127.0.0.1' in order to overcove the problem. That is why I didn't use 'from_string' instead of 'resolver'.

That's a good point!

I have seen in the documentation, that this function is deprecated:
https://www.boost.org/doc/libs/1_73_0/doc/html/boost_asio/reference/ip__tcp/resolver.html

(**Deprecated**: Use overload with separate host and service parameters.) Perform forward resolution of a query to a list of entries.
—
Perform forward resolution of a query to a list of entries.
—
Perform reverse resolution of an endpoint to a list of entries. 

With Boost 1.66.0 it doesn't works for me (Version 1.66.0 is the highest version available for Cygwin - i don't have tested it with the newest version 1.73.0).

Could you propose a solution with a simultaneously equivalent behavior to use 'localhost' and '127.0.0.1' like the address excluding the solution with 'resolver'?

I could try it, but i don't know Boost very good.

from redis-cpp.

tdv avatar tdv commented on August 20, 2024

Done

from redis-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.