// Closes the Context. Close will block until all related Sockets are closed, and all pending messages are either // physically transferred to the network or the socket's linger period expires. func (c *Context) Close() { for { r := C.zmq_term(c.ctx) if r == -1 { if C.my_errno() == C.EINTR { continue } panic(zmqerr()) } break } }
func zmqerr() error { eno := C.my_errno() switch eno { case C.ETERM: return ErrTerminated case C.EAGAIN: return ErrTimeout case C.EINTR: return ErrInterrupted } str := C.GoString(C.zmq_strerror(eno)) return errors.New(str) }
func (conn *Connection) lastError(query string) error { if err := C.my_error(&conn.c); *err != 0 { return &SqlError{Num: int(C.my_errno(&conn.c)), Message: C.GoString(err), Query: query} } return &SqlError{0, "Unknow", string(query)} }