public static void packHeader(PkgHeader header,byte[] bs) throws UnsupportedEncodingException {
  Arrays.fill(bs,0,FDHT_PROTO_PKG_HEADER_SIZE,(byte)0);
  ProtoCommon.int2buff(header.body_len,bs,PROTO_HEADER_BODY_LEN_INDEX);
  ProtoCommon.int2buff(header.key_hash_code,bs,PROTO_HEADER_KEY_HASH_CODE_INDEX);
  ProtoCommon.int2buff(header.timestamp,bs,PROTO_HEADER_TIMESTAMP_INDEX);
  ProtoCommon.int2buff(header.expires,bs,PROTO_HEADER_EXPIRES_INDEX);
  bs[PROTO_HEADER_CMD_INDEX]=header.cmd;
  bs[PROTO_HEADER_KEEP_ALIVE_INDEX]=header.keep_alive;
  bs[PROTO_HEADER_STATUS_INDEX]=header.status;
  return;
}

public static void packHeader ( PkgHeader header , byte [ ] bs ) throws UnsupportedEncodingException { Arrays . fill ( bs , 0 , FDHT_PROTO_PKG_HEADER_SIZE , ( byte ) 0 ) ; ProtoCommon . int2buff ( header . body_len , bs , PROTO_HEADER_BODY_LEN_INDEX ) ; ProtoCommon . int2buff ( header . key_hash_code , bs , PROTO_HEADER_KEY_HASH_CODE_INDEX ) ; ProtoCommon . int2buff ( header . timestamp , bs , PROTO_HEADER_TIMESTAMP_INDEX ) ; ProtoCommon . int2buff ( header . expires , bs , PROTO_HEADER_EXPIRES_INDEX ) ; bs [ PROTO_HEADER_CMD_INDEX ] = header . cmd ; bs [ PROTO_HEADER_KEEP_ALIVE_INDEX ] = header . keep_alive ; bs [ PROTO_HEADER_STATUS_INDEX ] = header . status ; return ; }
pack header by fastdht transfer protocol
