public class ProtoCommon extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
ProtoCommon.PkgHeader
package header info
|
static class |
ProtoCommon.PkgInfo
package info
|
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
buff2int(byte[] bs,
int offset)
big-endian buff convert to int
|
static byte[] |
int2buff(int n)
int convert to buff (big-endian)
|
static void |
int2buff(int n,
byte[] bs,
int offset)
int convert to buff (big-endian)
|
static void |
packHeader(ProtoCommon.PkgHeader header,
byte[] bs)
pack header by FastDHT transfer protocol
|
static void |
quit(Socket sock)
send quit command to server and close socket
|
static ProtoCommon.PkgHeader |
recvHeader(InputStream in,
byte expect_cmd,
long expect_body_len)
receive pack header
|
static ProtoCommon.PkgInfo |
recvPackage(InputStream in,
byte expect_cmd,
long expect_body_len)
receive whole pack
|
public static final byte FDHT_PROTO_CMD_QUIT
public static final byte FDHT_PROTO_CMD_SET
public static final byte FDHT_PROTO_CMD_INC
public static final byte FDHT_PROTO_CMD_GET
public static final byte FDHT_PROTO_CMD_DEL
public static final byte FDHT_PROTO_CMD_BATCH_SET
public static final byte FDHT_PROTO_CMD_BATCH_GET
public static final byte FDHT_PROTO_CMD_BATCH_DEL
public static final byte FDHT_PROTO_CMD_STAT
public static final byte FDHT_PROTO_CMD_GET_SUB_KEYS
public static final byte FDHT_PROTO_CMD_HEART_BEAT
public static final byte FDHT_PROTO_CMD_RESP
public static final int PROTO_HEADER_BODY_LEN_INDEX
public static final int PROTO_HEADER_KEY_HASH_CODE_INDEX
public static final int PROTO_HEADER_TIMESTAMP_INDEX
public static final int PROTO_HEADER_EXPIRES_INDEX
public static final int PROTO_HEADER_CMD_INDEX
public static final int PROTO_HEADER_KEEP_ALIVE_INDEX
public static final int PROTO_HEADER_STATUS_INDEX
public static final int FDHT_PROTO_PKG_HEADER_SIZE
public static final int FDHT_MAX_NAMESPACE_LEN
public static final int FDHT_MAX_OBJECT_ID_LEN
public static final int FDHT_MAX_SUB_KEY_LEN
public static final byte FDHT_FULL_KEY_SEPERATOR
public static final char FDHT_KEY_LIST_SEP_CHAR
public static final String FDHT_KEY_LIST_SEP_STR
public static final int FDHT_EXPIRES_NEVER
public static final int FDHT_EXPIRES_NONE
public static final int FDHT_MAX_FULL_KEY_LEN
public static void packHeader(ProtoCommon.PkgHeader header, byte[] bs) throws UnsupportedEncodingException
header - package headerbs - byte buffUnsupportedEncodingExceptionpublic static ProtoCommon.PkgHeader recvHeader(InputStream in, byte expect_cmd, long expect_body_len) throws IOException
in - input streamexpect_cmd - expect response commandexpect_body_len - expect response package body lengthIOExceptionpublic static ProtoCommon.PkgInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException
in - input streamexpect_cmd - expect response commandexpect_body_len - expect response package body lengthIOExceptionpublic static void quit(Socket sock) throws IOException
sock - the Socket objectIOExceptionpublic static byte[] int2buff(int n)
n - numberpublic static void int2buff(int n,
byte[] bs,
int offset)
n - numberbs - byte buffoffset - buff start indexpublic static int buff2int(byte[] bs,
int offset)
bs - 4 bytes buffoffset - start indexCopyright © 2017. All rights reserved.