Esempio n. 1
0
 public static byte[] getNBOPort(short p) {
   ByteBuffer buf = ByteBuffer.allocate(2);
   buf.putShort((short) p);
   buf.order(ByteOrder.BIG_ENDIAN);
   buf.rewind();
   byte[] rtn = new byte[2];
   buf.get(rtn);
   return rtn;
 }
Esempio n. 2
0
 public static byte[] getNBOHost(String h) {
   if (h.equals(PEER)) return null;
   byte hostBytes[] = h.getBytes();
   int len = Array.getLength(hostBytes);
   ByteBuffer buf = ByteBuffer.allocate(len);
   buf.put(hostBytes);
   buf.order(ByteOrder.BIG_ENDIAN);
   buf.rewind();
   return (buf.array());
 }