func (d *dnsDriver) ReadDNSPacket(visit func([]byte, time.Time) error) (didRead bool, err error) {
	var bytesRead uint32
	var key uintptr // returned by GetQueuedCompletionStatus, then ignored
	var ol *windows.Overlapped

	// NOTE: ideally we would pass a timeout of INFINITY to the GetQueuedCompletionStatus, but are using a
	// timeout of 0 and letting userspace do a busy loop to align better with the Linux code.
	err = windows.GetQueuedCompletionStatus(d.iocp, &bytesRead, &key, &ol, 0)
	if err != nil {
		if err == syscall.Errno(syscall.WAIT_TIMEOUT) {
			// this indicates that there was no queued completion status, this is fine
			return false, nil
		}

		return false, errors.Wrap(err, "could not get queued completion status")
	}

	var buf *readbuffer
	buf = (*readbuffer)(unsafe.Pointer(ol))

	fph := (*driver.FilterPacketHeader)(unsafe.Pointer(&buf.data[0]))
	captureTime := time.Unix(0, int64(fph.Timestamp))

	start := driver.FilterPacketHeaderSize

	if err := visit(buf.data[start:], captureTime); err != nil {
		return false, err
	}

	// kick off another read
	if err := windows.ReadFile(d.h.Handle, buf.data[:], nil, &(buf.ol)); err != nil && err != windows.ERROR_IO_PENDING {
		return false, err
	}

	return true, nil
}
// ReadDNSPacket visits a raw DNS packet if one is available.
ReadDNSPacket visits a raw DNS packet if one is available.
// ReadDNSPacket visits a raw DNS packet if one is available .
func (d *dnsDriver) ReadDNSPacket(visit func([]byte, time.Time) error) (didRead bool, err error) {
	var bytesRead uint32
	var key uintptr 
	var ol *windows.Overlapped
	err = windows.GetQueuedCompletionStatus(d.iocp, &bytesRead, &key, &ol, 0)
	if err != nil {
		if err == syscall.Errno(syscall.WAIT_TIMEOUT) {
			return false, nil
		}
		return false, errors.Wrap(err, "could not get queued completion status")
	}
	var buf *readbuffer
	buf = (*readbuffer)(unsafe.Pointer(ol))
	fph := (*driver.FilterPacketHeader)(unsafe.Pointer(&buf.data[0]))
	captureTime := time.Unix(0, int64(fph.Timestamp))
	start := driver.FilterPacketHeaderSize
	if err := visit(buf.data[start:], captureTime); err != nil {
		return false, err
	}
	if err := windows.ReadFile(d.h.Handle, buf.data[:], nil, &(buf.ol)); err != nil && err != windows.ERROR_IO_PENDING {
		return false, err
	}
	return true, nil
}
func ( d * dnsDriver ) ReadDNSPacket ( visit func ( [ ] byte , time . Time ) error ) ( didRead bool , err error ) { var bytesRead uint32 var key uintptr var ol * windows . Overlapped err = windows . GetQueuedCompletionStatus ( d . iocp , & bytesRead , & key , & ol , 0 ) if err != nil { if err == syscall . Errno ( syscall . WAIT_TIMEOUT ) { return false , nil } return false , errors . Wrap ( err , " " ) } var buf * readbuffer buf = ( * readbuffer ) ( unsafe . Pointer ( ol ) ) fph := ( * driver . FilterPacketHeader ) ( unsafe . Pointer ( & buf . data [ 0 ] ) ) captureTime := time . Unix ( 0 , int64 ( fph . Timestamp ) ) start := driver . FilterPacketHeaderSize if err := visit ( buf . data [ start : ] , captureTime ) ; err != nil { return false , err } if err := windows . ReadFile ( d . h . Handle , buf . data [ : ] , nil , & ( buf . ol ) ) ; err != nil && err != windows . ERROR_IO_PENDING { return false , err } return true , nil }
ReadDNSPacket visits a raw DNS packet if one is available.
ReadDNSPacket visits a raw DNS packet if one is available .
// returned by GetQueuedCompletionStatus, then ignored // NOTE: ideally we would pass a timeout of INFINITY to the GetQueuedCompletionStatus, but are using a // timeout of 0 and letting userspace do a busy loop to align better with the Linux code. // this indicates that there was no queued completion status, this is fine // kick off another read