def test_zmq_getsockopt(self): from zmq.cffi_core._cffi import C, ffi from zmq.cffi_core.constants import PUSH, IDENTITY ctx = C.zmq_ctx_new() socket = C.zmq_socket(ctx, PUSH) identity = ffi.new('char[]', 'zmq') ret = C.zmq_setsockopt(socket, IDENTITY, ffi.cast('void*', identity), 3) assert ret == 0 option_len = ffi.new('size_t*', 3) option = ffi.new('char*') ret = C.zmq_getsockopt(socket, IDENTITY, ffi.cast('void*', option), option_len) assert ret == 0 assert ffi.string(ffi.cast('char*', option))[0] == "z" assert ffi.string(ffi.cast('char*', option))[1] == "m" assert ffi.string(ffi.cast('char*', option))[2] == "q" assert ctx != ffi.NULL assert ffi.NULL != socket assert 0 == C.zmq_close(socket) assert 0 == C.zmq_ctx_destroy(ctx)
def test_zmq_setsockopt(self): from zmq.cffi_core._cffi import C, ffi from zmq.cffi_core.constants import PUSH, IDENTITY ctx = C.zmq_ctx_new() socket = C.zmq_socket(ctx, PUSH) identity = ffi.new('char[3]', 'zmq') ret = C.zmq_setsockopt(socket, IDENTITY, ffi.cast('void*', identity), 3) assert ret == 0 assert ctx != ffi.NULL assert ffi.NULL != socket assert 0 == C.zmq_close(socket) assert 0 == C.zmq_ctx_destroy(ctx)