       (.position buff oldpos)))
 
   ByteBuf
+  (read-short [buff pos]
+    (.getShort buff pos))
+  (write-short [buff pos value]
+    (.setShort buff pos value))
   (read-int [buff pos]
     (.getInt buff pos))
+  (write-int [buff pos value]
+    (.setInt buff pos value))
   (read-long [buff pos]
     (.getLong buff pos))
-  (write-int [buff pos value]
-    (.setInt buff pos value))
   (write-long [buff pos value]
     (.setLong buff pos value))
+  (read-byte [buff pos]
+    (.getByte buff pos))
+  (write-byte [buff pos value]
+    (.setByte buff pos value))
   (read-bytes [buff pos size]
     (let [tmpbuf (byte-array size)]
       (.getBytes buff tmpbuf)



(defprotocol IBuffer
  (read-int [_ pos] "Read an integer (32 bits) from buffer.")
  (write-int [_ pos value] "Write an integer to the buffer.")
  (read-long [_ pos] "Read an long (64 bits) from buffer.")
  (write-long [_ pos value] "Write an long to the buffer.")
  (read-bytes [_ pos size] "Read a byte array.")
  (write-bytes [_ pos size data] "Write byte array."))



(extend-protocol IBuffer
  ByteBuffer
  (read-short [buff pos]
    (.getShort buff pos))
  (write-short [buff pos value]
    (.putShort buff pos value))
  (read-int [buff pos]
    (.getInt buff pos))
  (write-int [buff pos value]
    (.putInt buff pos value))
  (read-long [buff pos]
    (.getLong buff pos))
  (write-long [buff pos value]
    (.putLong buff pos value))
  (read-byte [buff pos]
    (.get buff pos))
  (write-byte [buff pos value]
    (.put buff pos value))
  (read-bytes [buff pos size]
    (let [tmpbuf (byte-array size)
          oldpos (.position buff)]
