func writeResponse(w *bufio.Writer, b []byte) (err error) {
	if err = binary.Write(w, binary.BigEndian, int32(len(b))); err != nil {
		return
	}
	_, err = w.Write(b)
	return
}
func writeResponse(w *bufio.Writer, b []byte) (err error) {
	if err = binary.Write(w, binary.BigEndian, int32(len(b))); err != nil {
		return
	}
	_, err = w.Write(b)
	return
}
// =============================================================================
// These functions were adapted from https://github.com/nsqio/nsq