internal/protocol/segment.go
func (h *segmentHeader) read(rd *bufio.Reader) error {
	h.segmentLength = rd.ReadInt32()
	h.segmentOfs = rd.ReadInt32()
	h.noOfParts = rd.ReadInt16()
	h.segmentNo = rd.ReadInt16()
	h.segmentKind = segmentKind(rd.ReadInt8())

	switch h.segmentKind {

	default: //error
		rd.Skip(11) //segmentHeaderLength

	case skRequest:
		h.messageType = messageType(rd.ReadInt8())
		h.commit = rd.ReadBool()
		h.commandOptions = commandOptions(rd.ReadInt8())
		rd.Skip(8) //segmentHeaderLength

	case skReply:
		rd.Skip(1) //reserved
		h.functionCode = functionCode(rd.ReadInt16())
		rd.Skip(8) //segmentHeaderLength

	}

	if trace {
		outLogger.Printf("read segment header: %s", h)
	}

	return rd.GetError()
}
func (h *segmentHeader) read(rd *bufio.Reader) error {
	h.segmentLength = rd.ReadInt32()
	h.segmentOfs = rd.ReadInt32()
	h.noOfParts = rd.ReadInt16()
	h.segmentNo = rd.ReadInt16()
	h.segmentKind = segmentKind(rd.ReadInt8())

	switch h.segmentKind {

	default: //error
		rd.Skip(11) //segmentHeaderLength

	case skRequest:
		h.messageType = messageType(rd.ReadInt8())
		h.commit = rd.ReadBool()
		h.commandOptions = commandOptions(rd.ReadInt8())
		rd.Skip(8) //segmentHeaderLength

	case skReply:
		rd.Skip(1) //reserved
		h.functionCode = functionCode(rd.ReadInt16())
		rd.Skip(8) //segmentHeaderLength

	}

	if trace {
		outLogger.Printf("read segment header: %s", h)
	}

	return rd.GetError()
}
//  reply || error