func ReceiveWire(conn net.Conn, rxbuf []byte) (n int, addr *net.UDPAddr, err error) {
	switch x := conn.(type) {
	case *net.TCPConn:
		var b [2]byte
		if n, err = io.ReadFull(conn, b[:]); err != nil {
			return
		}

		n = int(b[0])<<8 | int(b[1])
		nr := 0
		if nr, err = io.ReadFull(conn, rxbuf[:n]); err != nil {
			err = fmt.Errorf("msg.ReceiveBuf size=%d(got %d): %s", n, nr, err)
		}
	case *net.UDPConn:
		n, addr, err = x.ReadFromUDP(rxbuf)
	default:
		err = fmt.Errorf("ReceiveWire: unsupported conn type %T", conn)
	}
	return
}
// ReceiveWire reads a DNS packet from conn, copying the payload into rxbuf.
// It returns the number of bytes copied into rxbuf.  If conn is a net.TCPConn
// then a 2 byte msg len prefix is expected firstly and those two prefix bytes
// are not reflected in the returned size n. If conn is a net.UPConn then the
// originating address is returned in addr, otherwise addr will be nil.
// ReceiveWire can hang forever if the conn doesn't have appropriate read
// timeout already set.
ReceiveWire reads a DNS packet from conn, copying the payload into rxbuf.
It returns the number of bytes copied into rxbuf.  If conn is a net.TCPConn
then a 2 byte msg len prefix is expected firstly and those two prefix bytes
are not reflected in the returned size n. If conn is a net.UPConn then the
originating address is returned in addr, otherwise addr will be nil.
ReceiveWire can hang forever if the conn doesn't have appropriate read
timeout already set.
// ReceiveWire reads a DNS packet from conn copying the payload into rxbuf . // It returns the number of bytes copied into rxbuf . If conn is a net . TCPConn // then a 2 byte msg len prefix is expected firstly and those two prefix bytes // are not reflected in the returned size n . If conn is a net . UPConn then the // originating address is returned in addr otherwise addr will be nil . // ReceiveWire can hang forever if the conn doesn ' t have appropriate read // timeout already set .
func ReceiveWire(conn net.Conn, rxbuf []byte) (n int, addr *net.UDPAddr, err error) {
	switch x := conn.(type) {
	case *net.TCPConn:
		var b [2]byte
		if n, err = io.ReadFull(conn, b[:]); err != nil {
			return
		}
		n = int(b[0])<<8 | int(b[1])
		nr := 0
		if nr, err = io.ReadFull(conn, rxbuf[:n]); err != nil {
			err = fmt.Errorf("msg.ReceiveBuf size=%d(got %d): %s", n, nr, err)
		}
	case *net.UDPConn:
		n, addr, err = x.ReadFromUDP(rxbuf)
	default:
		err = fmt.Errorf("ReceiveWire: unsupported conn type %T", conn)
	}
	return
}
func ReceiveWire ( conn net . Conn , rxbuf [ ] byte ) ( n int , addr * net . UDPAddr , err error ) { switch x := conn . ( type ) { case * net . TCPConn : var b [ 2 ] byte if n , err = io . ReadFull ( conn , b [ : ] ) ; err != nil { return } n = int ( b [ 0 ] ) << 8 | int ( b [ 1 ] ) nr := 0 if nr , err = io . ReadFull ( conn , rxbuf [ : n ] ) ; err != nil { err = fmt . Errorf ( " " , n , nr , err ) } case * net . UDPConn : n , addr , err = x . ReadFromUDP ( rxbuf ) default : err = fmt . Errorf ( " " , conn ) } return }
ReceiveWire reads a DNS packet from conn, copying the payload into rxbuf.
ReceiveWire reads a DNS packet from conn copying the payload into rxbuf .