I wonder what happens when I first create a TCPClient within a function scope, extract the NetworkStream out of it, pass that to the c-tor of a class and return the newly created object:
{
TcpClient client = new TcpClient();
await client.ConnectAsync(host, outport).ConfigureAwait(false);
NetworkStream stream = client.GetStream();
TCPWrapperAdapterWithStream adapter = new TCPWrapperAdapterWithStream(stream, stream, 100);
return adapter;
}
What happens with client after the context is left? Will stream still be working?
Can I do it in this way or do I have to "keep" the TCPClient object?