I am able to open a TcpClient connection in C#, open a network stream, and send commands successfully. I was able to login with a username and password. Then sent some commands to control the system and it works fine.
How can I send commands to that stream I already opened if I create a new form?
I want to open a new form and have the user push buttons that will send commands through the stream I already opened. I’m not exactly sure how to do this because I will run into errors if I try to open the same stream again.
You should make a separate class that encapsulates the network-related behaviour. Your TcpClient will be instantiated in that class. Then you can either pass a reference to that class to new forms in their constructor, or you can use the Singleton pattern.
Note that keeping unrelated behaviour (such as GUI and networking) separate is a Good Idea.