Use TcpClient.Connect().

This commit is contained in:
Ryan Petris 2020-09-19 22:22:48 +00:00
parent 0496e18179
commit 361f51ac94
No known key found for this signature in database
GPG key ID: C3D15EFA013E18C2

View file

@ -111,12 +111,12 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public async Task<bool> CheckTunerAvailability(IPAddress remoteIp, int tuner, CancellationToken cancellationToken) public async Task<bool> CheckTunerAvailability(IPAddress remoteIp, int tuner, CancellationToken cancellationToken)
{ {
using (var client = new TcpClient(remoteIp.ToString(), HdHomeRunPort)) using var client = new TcpClient();
using (var stream = client.GetStream()) client.Connect(remoteIp, HdHomeRunPort);
{
using var stream = client.GetStream();
return await CheckTunerAvailability(stream, tuner, cancellationToken).ConfigureAwait(false); return await CheckTunerAvailability(stream, tuner, cancellationToken).ConfigureAwait(false);
} }
}
private static async Task<bool> CheckTunerAvailability(NetworkStream stream, int tuner, CancellationToken cancellationToken) private static async Task<bool> CheckTunerAvailability(NetworkStream stream, int tuner, CancellationToken cancellationToken)
{ {
@ -142,7 +142,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
_remoteEndPoint = new IPEndPoint(remoteIp, HdHomeRunPort); _remoteEndPoint = new IPEndPoint(remoteIp, HdHomeRunPort);
_tcpClient = new TcpClient(_remoteEndPoint.Address.ToString(), _remoteEndPoint.Port); _tcpClient = new TcpClient();
_tcpClient.Connect(_remoteEndPoint);
if (!_lockkey.HasValue) if (!_lockkey.HasValue)
{ {
@ -221,9 +222,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return; return;
} }
using (var tcpClient = new TcpClient(_remoteEndPoint.Address.ToString(), _remoteEndPoint.Port)) using var tcpClient = new TcpClient();
using (var stream = tcpClient.GetStream()) tcpClient.Connect(_remoteEndPoint);
{
using var stream = tcpClient.GetStream();
var commandList = commands.GetCommands(); var commandList = commands.GetCommands();
byte[] buffer = ArrayPool<byte>.Shared.Rent(8192); byte[] buffer = ArrayPool<byte>.Shared.Rent(8192);
try try
@ -246,7 +248,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
ArrayPool<byte>.Shared.Return(buffer); ArrayPool<byte>.Shared.Return(buffer);
} }
} }
}
public Task StopStreaming(TcpClient client) public Task StopStreaming(TcpClient client)
{ {