func (c Cookie) Check() error {
	if c.replyChan != nil {
		return errors.New("Cannot call 'Check' on a cookie that is " +
			"expecting a *reply*. Use 'Reply' instead.")
	}
	if c.errorChan == nil {
		return errors.New("Cannot call 'Check' on a cookie that is " +
			"not expecting a possible *error*.")
	}
	select {
	case err := <-c.errorChan:
		return err
	case <-c.pingChan:
		return nil
	default:
	}
	c.conn.Sync()
	select {
	case err := <-c.errorChan:
		return err
	case <-c.pingChan:
		return nil
	}
}
Check is used for checked requests that have no replies. It is a mechanism
by which to report "success" or "error" in a synchronous fashion. (Therefore,
unchecked requests without replies cannot use this method.)
If the request causes an error, it is sent to this cookie's errorChan.
If the request was successful, there is no response from the server.
Thus, pingChan is sent a value when the *next* reply is read.
If no more replies are being processed, we force a round trip request with
GetInputFocus.

Unless you're building requests from bytes by hand, this method should
not be used.
package xgb
import (
	"errors"
)
type Cookie struct {
	conn      *Conn
	Sequence  uint16
	replyChan chan []byte
	errorChan chan error
	pingChan  chan bool
}
func (c *Conn) NewCookie(checked, reply bool) *Cookie {
	cookie := &Cookie{
		conn:      c,
		Sequence:  0,  
		replyChan: nil,
		errorChan: nil,
		pingChan:  nil,
	}
	if checked {
		cookie.errorChan = make(chan error, 1)
		if !reply {
			cookie.pingChan = make(chan bool, 1)
		}
	}
	if reply {
		cookie.replyChan = make(chan []byte, 1)
		if !checked {
			cookie.pingChan = make(chan bool, 1)
		}
	}
	return cookie
}
func (c Cookie) Reply() ([]byte, error) {
	if c.errorChan != nil {
		return c.replyChecked()
	}
	return c.replyUnchecked()
}
func (c Cookie) replyChecked() ([]byte, error) {
	if c.replyChan == nil {
		return nil, errors.New("Cannot call 'replyChecked' on a cookie that " +
			"is not expecting a *reply* or an error.")
	}
	if c.errorChan == nil {
		return nil, errors.New("Cannot call 'replyChecked' on a cookie that " +
			"is not expecting a reply or an *error*.")
	}
	select {
	case reply := <-c.replyChan:
		return reply, nil
	case err := <-c.errorChan:
		return nil, err
	}
}
func (c Cookie) replyUnchecked() ([]byte, error) {
	if c.replyChan == nil {
		return nil, errors.New("Cannot call 'replyUnchecked' on a cookie " +
			"that is not expecting a *reply*.")
	}
	select {
	case reply := <-c.replyChan:
		return reply, nil
	case <-c.pingChan:
		return nil, nil
	}
}