title: C#: Unable to receive large data on TCP Server
body: <p>I have created a TCP server. I am facing one problem. my TCP Server is not receiving data larger than 30000 bytes.</p>
  
  <p>here is code to receive data</p>
  
  <p><strong>MAX_TCP_DATA = 64000</strong></p>
  
  <pre><code>private void Process()
          {
              if (client.Connected == true)
              {
                  log.InfoFormat("Client connected :: {0}", client.Client.RemoteEndPoint);
                  Byte[] bytes = new Byte[MAX_TCP_DATA];
                  String data = null;
                  NetworkStream stream = client.GetStream();
  
                  int i;
  
                  try
                  {
                      // Loop to receive all the data sent by the client.
                      while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                      {
                          // bytes contains received data in byte[].
                          // Translate data bytes to a UTF-8 string.
                          byte[] receivedBuffer = new byte[i];
                          Array.Copy(bytes, receivedBuffer, i);
  
                          if (log.IsDebugEnabled)
                          {
                              data = System.Text.Encoding.UTF8.GetString(receivedBuffer);
                              log.InfoFormat("Received MSG ::: " + data);
                          }
  
                          CommEventArgs comEventArg = new CommEventArgs();
                          comEventArg.data = receivedBuffer;
                          IPEndPoint remoteIPEndPoint = (IPEndPoint)client.Client.RemoteEndPoint;
                          comEventArg.srcAddress = remoteIPEndPoint.Address.ToString();
                          comEventArg.srcPort = remoteIPEndPoint.Port;
                          comEventArg.length = i;
                          this.OnDataReceived(comEventArg);
                      }
                  }
                  catch (Exception ex)
                  {
                      log.InfoFormat("Client disconnected : {0}", client.Client.RemoteEndPoint);
                  }
                  finally
                  {
                     client.Close();
                  }
              }
          }
  </code></pre>
  
  <p>when i sent byte array of 40000. my TCP Server receives only 26280 bytes.</p>
  
  <p>Please tell me where is the problem in receiving.</p>