From 891c9189e8cdbf36bb03b96330b71774bc65bb75 Mon Sep 17 00:00:00 2001 From: Tim Schiewe Date: Wed, 8 Jan 2020 21:56:23 +0100 Subject: [PATCH 1/2] Fix query client connection fails with IPv6 --- TS3Client/Query/Ts3QueryClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/TS3Client/Query/Ts3QueryClient.cs b/TS3Client/Query/Ts3QueryClient.cs index f7cbc300..a583b5db 100644 --- a/TS3Client/Query/Ts3QueryClient.cs +++ b/TS3Client/Query/Ts3QueryClient.cs @@ -26,7 +26,7 @@ namespace TS3Client.Query public sealed class Ts3QueryClient : Ts3BaseFunctions { private readonly object sendQueueLock = new object(); - private readonly TcpClient tcpClient; + private TcpClient tcpClient; private NetworkStream tcpStream; private StreamReader tcpReader; private StreamWriter tcpWriter; @@ -50,7 +50,6 @@ public sealed class Ts3QueryClient : Ts3BaseFunctions public Ts3QueryClient() { connecting = false; - tcpClient = new TcpClient(); msgProc = new SyncMessageProcessor(MessageHelper.GetToClientNotificationType); dispatcher = new ExtraThreadEventDispatcher(); } @@ -64,6 +63,13 @@ public override void Connect(ConnectionData conData) { connecting = true; + // Create a new client instance using the correct address family, + // because it can't be adjusted after the underlying socket was + // created by TcpClient (default is IPv4, but come on, it's 2020). + // This prevents failing connections due to the address family + // of the socket not matching the address family of the given + // remote address when using IPv6. + tcpClient = new TcpClient(remoteAddress.AddressFamily); tcpClient.Connect(remoteAddress); ConnectionData = conData; From d25fb143cd0e85dea57c5e20e3c0fb349f7478f9 Mon Sep 17 00:00:00 2001 From: Splamy Date: Fri, 17 Jan 2020 19:35:43 +0100 Subject: [PATCH 2/2] Removed overly long comment --- TS3Client/Query/Ts3QueryClient.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/TS3Client/Query/Ts3QueryClient.cs b/TS3Client/Query/Ts3QueryClient.cs index a583b5db..b6614013 100644 --- a/TS3Client/Query/Ts3QueryClient.cs +++ b/TS3Client/Query/Ts3QueryClient.cs @@ -63,12 +63,6 @@ public override void Connect(ConnectionData conData) { connecting = true; - // Create a new client instance using the correct address family, - // because it can't be adjusted after the underlying socket was - // created by TcpClient (default is IPv4, but come on, it's 2020). - // This prevents failing connections due to the address family - // of the socket not matching the address family of the given - // remote address when using IPv6. tcpClient = new TcpClient(remoteAddress.AddressFamily); tcpClient.Connect(remoteAddress);