Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. TcpClient MyTcpClient;
  2. int myPort = 4000;
  3. StreamWriter MyWriter;
  4. StreamReader MyReader;
  5.  
  6. int port = GetFreePort();
  7.  
  8. MyTcpClient = new TcpClient(IPAddress.Loopback.Tostring(), port);
  9. MyTcpClient.ReceiveTimeout = 30000;
  10.  
  11. MyReader = new StreamReader(MyTcpClient.GetStream());
  12. MyWriter = new StreamWriter(MyTcpClient.GetStream());
  13.  
  14. while(MyTcpClient.Connected) //if device is off, it still true
  15. {
  16. string line = MyReader.ReadLine();// when device is off, it is null
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement