0

In a button click event I need to send 5 different commands recieve each output one by one.

My code for only one command is (its works):

TcpClient socketForServer;
            socketForServer = new TcpClient("127.0.0.1", 2211);
            NetworkStream networkStream = socketForServer.GetStream();
            System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
            System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(networkStream);

            string command = command.Text;
            streamWriter.WriteLine(command + "");
            streamWriter.Flush();

            //wait for and retrieve response

           string outputString;
   
           socketForServer.ReceiveTimeout = 5000;
           outputString = streamReader.ReadToEnd();
           textxml.Text = outputString;
...

For example:

send command1 socket recieve output1 in textbox1, then take value from xml
send command2 recieve ouput2 in textbox2, then take value from xml
etc...

My difficult is to create this kind of "cycle" of command, result in only one button click event. I need cycle because the other software from send the command only receive one command then gives the output, one by one.

Thanks in advance

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by sknake
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.