c# - Read from StreamReader doesn't reach the end - Using Telnet protocol -


i using telnet protocol in order query unix servers , output of commands. using minimalistic telnet code project , did slight modification enable reading output end of stream:

public void writecommand(string cmd) {     using (networkstream stream = tcpsocket.getstream())     {         using (streamwriter writer = new streamwriter(stream))         {             writer.autoflush = true;              using (streamreader reader = new streamreader(stream))             {                  string message = cmd;                  writer.writeline(message);                  writer.flush();                   while (!reader.endofstream)                  {                      string response = reader.readline();                      console.writeline(response);                  }              }          }      }  } 

the problem when run method, supposed return output till end, it's blocked because not recognizing end of stream, condition reader.endofstream() never reached.

can tell me what's problem code please?

as @itsme86 wrote connection remains open. expect response commands being send? if true read response, parse it, find delimiter or other finish symbol mark command has been executed , break while().


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -