title: C# ProtoBuf with TcpClient How can i separate packets?
body: <p>I want to send two person classes.</p>
  
  <pre><code>[ProtoContract]
  class Person {
      [ProtoMember(1)]
      public int Id {get;set;}
      [ProtoMember(2)]
      public string Name { get; set; }
      [ProtoMember(3)]
      public Address Address {get;set;}
  }
  [ProtoContract]
  class Address {
      [ProtoMember(1)]
      public string Line1 {get;set;}
      [ProtoMember(2)]
      public string Line2 {get;set;}
  }
  </code></pre>
  
  <p>This class is from the <a href="https://code.google.com/p/protobuf-net/wiki/GettingStarted" rel="nofollow">https://code.google.com/p/protobuf-net/wiki/GettingStarted</a></p>
  
  <p>And, now i coded client like this.</p>
  
  <pre><code>TcpClient tcp_client = new TcpClient("localhost", 33333);
              var p1 = new Person
              {
                  Id = 12345,
                  Name = "John1",
                  Address = new Address
                  {
                      Line1 = "USA",
                      Line2 = "New york",
                  }
              };
              var p2 = new Person
              {
                  Id = 54321,
                  Name = "John2",
                  Address = new Address
                  {
                      Line1 = "USA",
                      Line2 = "New york",
                  }
              };
  
              NetworkStream ns = tcp_client.GetStream();
              Serializer.Serialize(ns, p1);
              Serializer.Serialize(ns, p2);
  
              tcp_client.Close();
              Console.Read();
  </code></pre>
  
  <p>Here, <code>Person</code> <strong>p1</strong> and <code>Person</code> <strong>p2</strong> are serialized to remote server.</p>
  
  <p>This is the server.</p>
  
  <pre><code>static void Main(string[] args)
          {
              IPAddress ipAddress = System.Net.Dns.GetHostEntry("localhost").AddressList[0];
              TcpListener svr = new TcpListener(ipAddress, 33333);
              svr.Start();
  
              var client = svr.AcceptTcpClient();
              byte[] b = new byte[1024];
              int read = client.GetStream().Read(b, 0, 1024);
              client.Close();
              svr.Stop();
  
              // Now parse packet.
              byte[] bb = new byte[read];
              Array.Copy(b, bb, read);
  
              // If in one time received two persons, how can i separate it?
              Console.Read();
          }
  </code></pre>
  
  <p>Here, if in one time received all persons (two) by byte array, how can i separate it?</p>
  
  <p>Thanks in advance...</p>