func RxAll(conn *net.TCPConn, zone string, msgHandler RxMsgHandler, errHandler ErrHandler) (err error) {
	serial := 0
	defer func() {
		if e := recover(); e != nil {
			err = e.(error)
			if errHandler == nil || !errHandler(serial, err) {
				return
			}

			err = nil // handled by errHandler
		}
	}()

	m := msg.New()
	m.Append(zone, msg.QTYPE_AXFR, rr.CLASS_IN)
	if err = m.Send(conn); err != nil && (errHandler == nil || !errHandler(-1, err)) {
		return
	}

	rxbuf := make([]byte, 1<<16)
	id := m.Header.ID

	for serial := 0; ; serial++ {
		rxbuf = rxbuf[:cap(rxbuf)]
		if _, err = m.ReceiveTCP(conn, rxbuf); err != nil && (errHandler == nil || !errHandler(serial, err)) {
			return
		}

		if h := &m.Header; h.ID != id ||
			!h.QR ||
			h.Opcode != m.Header.Opcode ||
			h.TC ||
			h.Z ||
			h.QDCOUNT != 1 {
			if errHandler == nil || !errHandler(serial, &Error{"invalid msg received", m}) {
				return
			}
		}

		if !msgHandler(serial, m) {
			return nil
		}
	}

	panic("unreachable")
}
// RxAll attemtps to perform an AXFR zone 'zone' transfer through conn.
//
// On every msg received the msgHandler is invoked. If this handler returns false
// then the transfer is aborted and a nil Error is returned. The msgHandler should
// return false on seeing a message with the 'closing' SOA RR, otherwise the behavior of RxAll us undefined.
//
// If the errHandler is nil then any error in the xfer causes the transfer to be aborted
// and the error is returned.
//
// If the errHandler is non nil then any error in the xfer is handled over to the errHandler.
// If the errHandler returns false, the transfer is aborted and the same err is returned.
// If the error is from sending the initial query then the serial parameter is < 0.
//
// This function *never* closes the conn.
RxAll attemtps to perform an AXFR zone 'zone' transfer through conn.

On every msg received the msgHandler is invoked. If this handler returns false
then the transfer is aborted and a nil Error is returned. The msgHandler should
return false on seeing a message with the 'closing' SOA RR, otherwise the behavior of RxAll us undefined.

If the errHandler is nil then any error in the xfer causes the transfer to be aborted
and the error is returned.

If the errHandler is non nil then any error in the xfer is handled over to the errHandler.
If the errHandler returns false, the transfer is aborted and the same err is returned.
If the error is from sending the initial query then the serial parameter is < 0.

This function *never* closes the conn.
// RxAll attemtps to perform an AXFR zone ' zone ' transfer through conn . // // On every msg received the msgHandler is invoked . If this handler returns false // then the transfer is aborted and a nil Error is returned . The msgHandler should // return false on seeing a message with the ' closing ' SOA RR otherwise the behavior of RxAll us undefined . // // If the errHandler is nil then any error in the xfer causes the transfer to be aborted // and the error is returned . // // If the errHandler is non nil then any error in the xfer is handled over to the errHandler . // If the errHandler returns false the transfer is aborted and the same err is returned . // If the error is from sending the initial query then the serial parameter is < 0 . // // This function * never * closes the conn .
func RxAll(conn *net.TCPConn, zone string, msgHandler RxMsgHandler, errHandler ErrHandler) (err error) {
	serial := 0
	defer func() {
		if e := recover(); e != nil {
			err = e.(error)
			if errHandler == nil || !errHandler(serial, err) {
				return
			}
			err = nil 
		}
	}()
	m := msg.New()
	m.Append(zone, msg.QTYPE_AXFR, rr.CLASS_IN)
	if err = m.Send(conn); err != nil && (errHandler == nil || !errHandler(-1, err)) {
		return
	}
	rxbuf := make([]byte, 1<<16)
	id := m.Header.ID
	for serial := 0; ; serial++ {
		rxbuf = rxbuf[:cap(rxbuf)]
		if _, err = m.ReceiveTCP(conn, rxbuf); err != nil && (errHandler == nil || !errHandler(serial, err)) {
			return
		}
		if h := &m.Header; h.ID != id ||
			!h.QR ||
			h.Opcode != m.Header.Opcode ||
			h.TC ||
			h.Z ||
			h.QDCOUNT != 1 {
			if errHandler == nil || !errHandler(serial, &Error{"invalid msg received", m}) {
				return
			}
		}
		if !msgHandler(serial, m) {
			return nil
		}
	}
	panic("unreachable")
}
func RxAll ( conn * net . TCPConn , zone string , msgHandler RxMsgHandler , errHandler ErrHandler ) ( err error ) { serial := 0 defer func ( ) { if e := recover ( ) ; e != nil { err = e . ( error ) if errHandler == nil || ! errHandler ( serial , err ) { return } err = nil } } ( ) m := msg . New ( ) m . Append ( zone , msg . QTYPE_AXFR , rr . CLASS_IN ) if err = m . Send ( conn ) ; err != nil && ( errHandler == nil || ! errHandler ( - 1 , err ) ) { return } rxbuf := make ( [ ] byte , 1 << 16 ) id := m . Header . ID for serial := 0 ; ; serial ++ { rxbuf = rxbuf [ : cap ( rxbuf ) ] if _ , err = m . ReceiveTCP ( conn , rxbuf ) ; err != nil && ( errHandler == nil || ! errHandler ( serial , err ) ) { return } if h := & m . Header ; h . ID != id || ! h . QR || h . Opcode != m . Header . Opcode || h . TC || h . Z || h . QDCOUNT != 1 { if errHandler == nil || ! errHandler ( serial , & Error { " " , m } ) { return } } if ! msgHandler ( serial , m ) { return nil } } panic ( " " ) }
RxAll attemtps to perform an AXFR zone 'zone' transfer through conn.
RxAll attemtps to perform an AXFR zone ' zone ' transfer through conn .
// handled by errHandler