title: Connecting to telnet server and send/recieve data
body: <p>So I am trying to connect to my telnet server, which works. It recives the first lot of data from the server which is us being asked to enter password to connect. But when I type in the password it does nothing and nothing that is recieved is printed to my console.</p>
  
  <p>An example of the output is as follows:</p>
  
  <pre><code>Connected to server.
  Please enter password:
  Response: MYPASSHERE
  __BLANK RESPONSE FROM SERVER__
  Response:
  </code></pre>
  
  <p><img src="https://puu.sh/flM2h/260ca960cd.png" alt="enter image description here"></p>
  
  <p>I am currently using this code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Net.Sockets;
  using System.Threading;
  
  namespace _7DaysServerManager
  {
      public class ServerSocket
      {
          private TcpClient client;
          private Thread readWriteThread;
          private NetworkStream networkStream;
          private string password;
  
          public ServerSocket(string ip, int port)
          {
              try
              {
                  client = new TcpClient(ip, port);
                  Console.WriteLine("Connected to server.");
              } 
              catch (SocketException)
              {
                  Console.WriteLine("Failed to connect to server");
                  return;
              }
  
              //Assign networkstream
              networkStream = client.GetStream();
  
              //start socket read/write thread
              readWriteThread = new Thread(readWrite);
              readWriteThread.Start();
          }
  
          private void readWrite()
          {
              string command, recieved;
  
              //Read first thing givent o us
              recieved = read();
              Console.WriteLine(recieved);
  
              //Set up connection loop
              while (true) 
              {
                  Console.Write("Response: ");
                  command = Console.ReadLine();
  
                  if (command == "exit")
                      break;
  
                  write(command);
                  recieved = read();
  
                  Console.WriteLine(recieved);
              }
  
              Console.WriteLine("Disconnected from server");
              networkStream.Close();
              client.Close();
          }
  
          public void write(string message)
          {
              networkStream.Write(Encoding.ASCII.GetBytes(message), 0, message.Length);
              networkStream.Flush();
          }
  
          public string read()
          {
              byte[] data = new byte[1024];
              string recieved = "";
  
              int size = networkStream.Read(data, 0, data.Length);
              recieved = Encoding.ASCII.GetString(data, 0, size);
  
              return recieved;
          }
      }
  }
  </code></pre>