title: How to parse data in C++
body: <pre><code>  final byte LOGIN_REQUEST = 1;
    long deviceId = 123456789;
    String nickname = "testid";
  
    Socket mSocket = new Socket("localhost", 12021);
    ByteBuffer bBuffer = ByteBuffer.allocate(1);
    bBuffer.order(ByteOrder.LITTLE_ENDIAN);
  
    //1
    bBuffer.put(LOGIN_REQUEST);
  
    //8
    bBuffer.putLong(deviceId);
  
    byte[] bString = nickname.getBytes();
    int sLength = bString.length;
  
    //4
    bBuffer.putInt(sLength);
    bBuffer.put(bString);
  </code></pre>
  
  <p>I am sending byte data like this and I want to parse it on my linux server using c++</p>
  
  <p>In c++, I am reading </p>
  
  <pre><code> char *pdata = new char[BUF_SIZE];
   int dataLength = read(m_events[i].data.fd, pdata, BUF_SIZE);
  </code></pre>
  
  <p>and push the pdata into the pthread's queue. I think I have to read first byte to see the type of the packet and read the next 8byte to get the device id and so on..
  Please give me some references or tutorial to do this in c++ code..</p>
  
  <p>Thanks in advance..</p>