Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TcpClient MyTcpClient;
- int myPort = 4000;
- StreamWriter MyWriter;
- StreamReader MyReader;
- int port = GetFreePort();
- MyTcpClient = new TcpClient(IPAddress.Loopback.Tostring(), port);
- MyTcpClient.ReceiveTimeout = 30000;
- MyReader = new StreamReader(MyTcpClient.GetStream());
- MyWriter = new StreamWriter(MyTcpClient.GetStream());
- while(MyTcpClient.Connected) //if device is off, it still true
- {
- string line = MyReader.ReadLine();// when device is off, it is null
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement