Exemplo n.º 1
0
        static LibZmq()
        {
            NativeLib = new UnmanagedLibrary(LibraryName);

            AssignCommonDelegates();
            AssignCurrentVersion(out MajorVersion, out MinorVersion, out PatchVersion);

            if (MajorVersion >= 3)
            {
                zmq_getmsgopt     = NativeLib.GetUnmanagedFunction <ZmqGetMsgOptProc>("zmq_getmsgopt");
                zmq_recvmsg       = NativeLib.GetUnmanagedFunction <ZmqRecvMsgProc>("zmq_recvmsg");
                zmq_sendmsg       = NativeLib.GetUnmanagedFunction <ZmqSendMsgProc>("zmq_sendmsg");
                zmq_msg_init_data = NativeLib.GetUnmanagedFunction <ZmqMsgInitDataProc>("zmq_msg_init_data");
                zmq_msg_move      = NativeLib.GetUnmanagedFunction <ZmqMsgMoveProc>("zmq_msg_move");

                PollTimeoutRatio = 1;
            }
            else if (MajorVersion == 2)
            {
                zmq_recvmsg = NativeLib.GetUnmanagedFunction <ZmqRecvMsgProc>("zmq_recv");
                zmq_sendmsg = NativeLib.GetUnmanagedFunction <ZmqSendMsgProc>("zmq_send");

                PollTimeoutRatio = 1000;
            }
        }
Exemplo n.º 2
0
        static LibZmq()
        {
            NativeLib = new UnmanagedLibrary(LibraryName);

            AssignCommonDelegates();
            AssignCurrentVersion(out MajorVersion, out MinorVersion, out PatchVersion);

            if (MajorVersion >= 3)
            {
                zmq_msg_get       = NativeLib.GetUnmanagedFunction <ZmqMsgGetProc>("zmq_msg_get");
                zmq_msg_init_data = NativeLib.GetUnmanagedFunction <ZmqMsgInitDataProc>("zmq_msg_init_data");
                zmq_msg_move      = NativeLib.GetUnmanagedFunction <ZmqMsgMoveProc>("zmq_msg_move");

                zmq_msg_recv = NativeLib.GetUnmanagedFunction <ZmqMsgRecvProc>("zmq_msg_recv");
                zmq_msg_send = NativeLib.GetUnmanagedFunction <ZmqMsgSendProc>("zmq_msg_send");

                zmq_buffer_recv = NativeLib.GetUnmanagedFunction <ZmqBufferRecvProc>("zmq_recv");
                zmq_buffer_send = NativeLib.GetUnmanagedFunction <ZmqBufferSendProc>("zmq_send");

                zmq_ctx_new        = NativeLib.GetUnmanagedFunction <ZmqCtxNewProc>("zmq_ctx_new");
                zmq_ctx_destroy    = NativeLib.GetUnmanagedFunction <ZmqCtxDestroyProc>("zmq_ctx_destroy");
                zmq_ctx_get        = NativeLib.GetUnmanagedFunction <ZmqCtxGetProc>("zmq_ctx_get");
                zmq_ctx_set        = NativeLib.GetUnmanagedFunction <ZmqCtxSetProc>("zmq_ctx_set");
                zmq_socket_monitor = NativeLib.GetUnmanagedFunction <ZmqSocketMonitorProc>("zmq_socket_monitor");

                zmq_unbind     = NativeLib.GetUnmanagedFunction <ZmqBindProc>("zmq_unbind");
                zmq_disconnect = NativeLib.GetUnmanagedFunction <ZmqConnectProc>("zmq_disconnect");

                PollTimeoutRatio = 1;
                ZmqMsgTSize      = Zmq3MsgTSize;
            }
            else if (MajorVersion == 2)
            {
                var zmq_msg_recv_impl = NativeLib.GetUnmanagedFunction <ZmqMsgRecvProc>("zmq_recv");
                var zmq_msg_send_impl = NativeLib.GetUnmanagedFunction <ZmqMsgSendProc>("zmq_send");
                zmq_msg_recv = (msg, sck, flags) => zmq_msg_recv_impl(sck, msg, flags);
                zmq_msg_send = (msg, sck, flags) => zmq_msg_send_impl(sck, msg, flags);

                zmq_buffer_recv = null;
                zmq_buffer_send = null;

                var zmq_init = NativeLib.GetUnmanagedFunction <ZmqInitProc>("zmq_init");
                zmq_ctx_new     = () => zmq_init(1);
                zmq_ctx_destroy = NativeLib.GetUnmanagedFunction <ZmqCtxDestroyProc>("zmq_term");

                PollTimeoutRatio = 1000;
                ZmqMsgTSize      = Zmq2MsgTSize;
            }
        }