title: Not Recieving data into text file on sending Machine Credentials in TCP/IP protocol
body: <p>I have a PBX machine which i need to communicate using Ip and Port number along with the username and password.At present i am able to connect to the machine by using the ip address and port number.But On sending the Username and password to the machine for authentication i am not getting the required data out from the machine into the text file instead i am getting the username and password send to the machine in format like this into the text file.</p>
  
  <p>Here is my code in c#.. </p>
  
  <pre><code>        ipaddress = "";
          int port = int.Parse("");
          textfileSaveLocation = "";
  
          byte[] data = new byte[1024];
          string stringData;
          //string input;
  
              IPAddress ipadd = IPAddress.Parse(ipaddress);
              IPEndPoint ipend = new IPEndPoint(ipadd,port);
              Socket sock = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
              sock.NoDelay = false;
              try
              {
                  sock.Connect(ipend);
                  textBox4.AppendText("Connected to host" + "\r\n");
              }
              catch (Exception dfg)
              {
                  textBox4.AppendText("Problem connecting to host" + "\r\n");
                  textBox4.AppendText(dfg.ToString ()+"\r\n");
                  return;
              }
              try
              {
                  int recv = sock.Receive(data);
                  stringData = Encoding.ASCII.GetString(data, 0, recv);
                  textBox4.AppendText(stringData + "\r\n");
                  while (true)
                  {
                      Byte[] bBuf;
                      string buf;
  
  
                      Application.DoEvents();
  
                      buf = String.Format("{0}/{1}", "SMDR", "PCCSMDR");
                      bBuf = Encoding.ASCII.GetBytes(buf);
                      sock.Send(bBuf);     
  
  
                      data = new byte[1024];
                      recv = sock.Receive(data);
                      stringData = Encoding.ASCII.GetString(data, 0, recv);
                      textBox4.AppendText(stringData + "\r\n");
                      string df = "";
                       try
  
          }
  </code></pre>
  
  <p>I am trying to figure out the mistake from two days but not able to find out..Just help me out where i am going wrong..</p>