1.accepts host, port and a text string.
2.connects to a host/port and sends the string (+ two lines feeds \r\n\r\n )when you click a button.
3.then reads the results and puts the results back in a text box.
The problem that i get a result of the port and string , BUT I DON'T GET ANYTHING ABOUT THE HOST.
This is what i've got so far:
Expand|Select|Wrap|Line Numbers
- private void button1_Click(object sender, EventArgs e)
- {
- string port = port1.Text;
- int myParsedInt = Int32.Parse(port);
- System.Net.IPAddress[] adresslist = Dns.GetHostAddresses(host1.Text);
- Socket connectSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- connectSocket.Connect(adresslist[0], myParsedInt);
- System.IO.StreamReader connectionRead = new System.IO.StreamReader(new NetworkStream(connectSocket));
- connectSocket.Send(System.Text.Encoding.UTF8.GetBytes(sendText.Text + "\r\n"));
- while (connectionRead.Peek() >= 0)
- {
- this.textOutput.AppendText(connectionRead.ReadLine() + "\r\n");
- }
- connectSocket.Close();
- }