Beispiel #1
0
// 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
	}
}
Beispiel #2
0
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)
}
Beispiel #3
0
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)}
}