Skip to content
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

Connect through host:port instead of Endpoint (not working under Ubuntu) #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CSRedis/CSRedis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
11 changes: 9 additions & 2 deletions CSRedis/Internal/IO/RedisSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public RedisSocket(bool ssl)
public void Connect(EndPoint endpoint)
{
InitSocket(endpoint);
_socket.Connect(endpoint);
if (endpoint is DnsEndPoint)
{
var host = (endpoint as DnsEndPoint).Host;
var port = (endpoint as DnsEndPoint).Port;
_socket.Connect(host,port);
}
else if (endpoint is IPEndPoint)
_socket.Connect((endpoint as IPEndPoint));
}

public bool ConnectAsync(SocketAsyncEventArgs args)
Expand Down Expand Up @@ -72,7 +79,7 @@ void InitSocket(EndPoint endpoint)
if (_socket != null)
_socket.Dispose();

_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_socket = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_remote = endpoint;
}

Expand Down
2 changes: 1 addition & 1 deletion CSRedis/RedisClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public RedisClient(string host, int port, int asyncConcurrency, int asyncBufferS
/// <param name="asyncConcurrency">Max concurrent threads (default 1000)</param>
/// <param name="asyncBufferSize">Async thread buffer size (default 10240 bytes)</param>
public RedisClient(string host, int port, bool ssl, int asyncConcurrency, int asyncBufferSize)
: this(new DnsEndPoint(host, port), ssl, asyncConcurrency, asyncBufferSize)
: this(new DnsEndPoint(host, port, System.Net.Sockets.AddressFamily.InterNetwork), ssl, asyncConcurrency, asyncBufferSize)
{ }

/// <summary>
Expand Down