Below are the parameters to send via socket in 5 byte data:
Parameters : methodname(1 byte), payloadlength(2 byte), payload(2 byte)
methodName = 5
payload = 2151
i want to send above three data in only 5 byte. The final sending byte are 0500020867. how to get this final bytes ?
  int methodname = 5;
  int payload  = 2151;
  ByteBuffer b = ByteBuffer.allocate(4);
        b.putInt(payload);
        byte[] payloadData = b.array();
        int payloadlength = payloadData.length;
    byte[] result = new byte[5];
    result[0] = (byte) (methodname);
    result[1] = (byte) (payloadlength >> 8);
    result[2] = (byte) (payloadlength);
    result[3] = (byte) (payload >> 8);
    result[4] = (byte) (payload);
    for (int i = 0; i < 5; i++)
             System.out.printf("%x\n", result[i]);
    result: 5 0 4 8 67 
    //expected result: 05 00 02 08 67
Can anybody help me out. Any sort of help would be appreciable. Thanks, Akash