using PVHelpers; using System.Net; using System.Net.Sockets; namespace RemoteFrameBuffer.Client { public class RemoteFrameBufferTcpClientStreamProvider : IRemoteFrameBufferClientStreamProvider { private readonly INetEndPoint remoteEndPoint; private readonly IPEndPoint localEndPoint; public RemoteFrameBufferTcpClientStreamProvider(INetEndPoint remoteEndPoint, IPEndPoint? localEndPoint) { this.remoteEndPoint = remoteEndPoint; this.localEndPoint = localEndPoint ?? new(IPAddress.Any, 0); } public Stream GetRemoteFrameBufferClientStream() { TcpClient tcpClient = new TcpClient(this.localEndPoint); tcpClient.Connect(this.remoteEndPoint.EndPoint); return tcpClient.GetStream(); } public RemoteFrameBufferTcpClientStreamProvider(String hostname, Int16 port, IPEndPoint? localEndPoint = null) : this(new NetEndPointFromHostname(hostname, port), localEndPoint) { } public RemoteFrameBufferTcpClientStreamProvider(IPAddress address, Int32 port, IPEndPoint? localEndPoint = null) : this(new NetEndPointFromIP(address, port), localEndPoint) { } public RemoteFrameBufferTcpClientStreamProvider(IPEndPoint remoteEndPoint, IPEndPoint? localEndPoint = null) : this(new NetEndPointFromIP(remoteEndPoint), localEndPoint) { } } }