Facebook
From Bulky Tern, 6 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 239
  1.         private string _ipAddress = "192.168.56.101";
  2.         private int _port = 9004;
  3.         public string SendMessage()
  4.         {
  5.             TcpClient client = new TcpClient(_ipAddress, _port);
  6.             NetworkStream test = client.GetStream();
  7.             byte[] byteToSend = ASCIIEncoding.ASCII.GetBytes("000102sdsadsa^");
  8.  
  9.             test.Write(byteToSend, 0, byteToSend.Length);
  10.  
  11.             byte[] bytesToRead = new byte[client.ReceiveBufferSize];
  12.             int bytesRead = test.Read(bytesToRead, 0, client.ReceiveBufferSize);
  13.             var getMessage = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);
  14.             client.Close();
  15.  
  16.             return getMessage;
  17.         }