Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. private void button33_Click(object sender, EventArgs e)
  2. {
  3.  
  4.  
  5. // Create a TcpClient.
  6. // Note, for this client to work you need to have a TcpServer
  7. // connected to the same address as specified by the server, port
  8. // combination.
  9. Int32 port = 11000;
  10. string message = "User:Кузнецов Андрей Сергеевич, Pass: arakul";
  11. string server = "http://www.zapomnika.zzz.com.ua/";
  12. TcpClient client = new TcpClient(server, port);
  13.  
  14. // Translate the passed message into ASCII and store it as a Byte array.
  15. Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
  16.  
  17. // Get a client stream for reading and writing.
  18. // Stream stream = client.GetStream();
  19.  
  20. NetworkStream stream = client.GetStream();
  21.  
  22. // Send the message to the connected TcpServer.
  23. stream.Write(data, 0, data.Length);
  24.  
  25.  
  26.  
  27. // Receive the TcpServer.response.
  28.  
  29. // Buffer to store the response bytes.
  30. data = new Byte[256];
  31.  
  32. // String to store the response ASCII representation.
  33. String responseData = String.Empty;
  34.  
  35. // Read the first batch of the TcpServer response bytes.
  36. Int32 bytes = stream.Read(data, 0, data.Length);
  37. responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
  38.  
  39. // Close everything.
  40. stream.Close();
  41. client.Close();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement