Skip to content

Can't connect localhost #56

@iassasin

Description

@iassasin

Hello, I'd tried to use connection to localhost with this code:

boost::asio::io_service io;
boost::asio::ip::tcp::resolver resolver(io);
boost::asio::ip::tcp::resolver::query query("localhost", "6379");
auto ep = resolver.resolve(query)->endpoint();
redisclient::RedisSyncClient redisInstance;
redisInstance.connect(ep);

but it fails with exception "Invalid argument". I made a research and found out the problem: boost 1.62 resolves localhost as ipv6 endpoint "::1", but redisclient supports only ipv4 (redissyncclient.cpp:65):

addr.sin_family = AF_INET;
addr.sin_port = htons(endpoint.port());
addr.sin_addr.s_addr = inet_addr(endpoint.address().to_string().c_str());

Hope it helps :)

P.S.: Latest version, commit f55ffdc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions