cnblogs / EnyimMemcachedCore

.NET Memcached client. Available on https://www.nuget.org/packages/EnyimMemcachedCore
Apache License 2.0
162 stars 45 forks source link

IPv6 host support #201

Closed caspChristian closed 9 months ago

caspChristian commented 1 year ago

Trying to use Host "::1" as server gives: An address incompatible with the requested protocol was use

This might only need to change https://github.com/cnblogs/EnyimMemcachedCore/blob/main/src/Enyim.Caching/Memcached/PooledSocket.cs#L36-L38

into:

            var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
            socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);
            socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
            socket.NoDelay = true;

It should allow any IP, both legacy IPv4 and current IPv6.

Other places where AddressFamily.InterNetwork is used in the code, might need an update as well.

cnblogs-dudu commented 11 months ago

Added support in 2.7.0. Please try it.

cnblogs-dudu commented 11 months ago

Set UseIPv6 option to true