Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button33_Click(object sender, EventArgs e)
- {
- // Create a TcpClient.
- // Note, for this client to work you need to have a TcpServer
- // connected to the same address as specified by the server, port
- // combination.
- Int32 port = 11000;
- string message = "User:Кузнецов Андрей Сергеевич, Pass: arakul";
- string server = "http://www.zapomnika.zzz.com.ua/";
- TcpClient client = new TcpClient(server, port);
- // Translate the passed message into ASCII and store it as a Byte array.
- Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
- // Get a client stream for reading and writing.
- // Stream stream = client.GetStream();
- NetworkStream stream = client.GetStream();
- // Send the message to the connected TcpServer.
- stream.Write(data, 0, data.Length);
- // Receive the TcpServer.response.
- // Buffer to store the response bytes.
- data = new Byte[256];
- // String to store the response ASCII representation.
- String responseData = String.Empty;
- // Read the first batch of the TcpServer response bytes.
- Int32 bytes = stream.Read(data, 0, data.Length);
- responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
- // Close everything.
- stream.Close();
- client.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement