コード例 #1
0
ファイル: LibZmq.Mono.cs プロジェクト: PhilippeChessa/clrzmq
        static LibZmq()
        {
            AssignCurrentVersion(out MajorVersion, out MinorVersion, out PatchVersion);

            if (MajorVersion >= 3)
            {
                zmq_msg_recv = zmq_msg_recv_v3;
                zmq_msg_send = zmq_msg_send_v3;

                zmq_buffer_recv = zmq_recvbuf_v3;
                zmq_buffer_send = zmq_sendbuf_v3;

                zmq_msg_get = zmq_msg_get_v3;
                zmq_msg_init_data = zmq_msg_init_data_v3;
                zmq_msg_move = zmq_msg_move_v3;

                zmq_ctx_get = zmq_ctx_get_v3;
                zmq_ctx_set = zmq_ctx_set_v3;
                zmq_socket_monitor = zmq_socket_monitor_v3;

                zmq_unbind = zmq_unbind_v3;
                zmq_disconnect = zmq_disconnect_v3;

                PollTimeoutRatio = 1;
                ZmqMsgTSize = Zmq3MsgTSize;

                zmq_ctx_new = zmq_ctx_new_v3;
                zmq_ctx_destroy = zmq_ctx_destroy_v3;
            }
            else if (MajorVersion == 2)
            {
                zmq_msg_recv = (msg, sck, flags) => zmq_recvmsg(sck, msg, flags);
                zmq_msg_send = (msg, sck, flags) => zmq_sendmsg(sck, msg, flags);

                zmq_buffer_recv = null;
                zmq_buffer_send = null;

                zmq_msg_get = (message, option, optval, optvallen) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 1); };
                zmq_msg_init_data = (msg, data, size, ffn, hint) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 1); };
                zmq_msg_move = (destmsg, srcmsg) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 1); };

                zmq_ctx_get = (ctx, opt) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 2); };
                zmq_ctx_set = (ctx, opt, val) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 2); };
                zmq_socket_monitor = (sck, addr, e) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 2); };

                zmq_unbind = (sck, addr) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 2); };
                zmq_disconnect = (sck, addr) => { throw new ZmqVersionException(MajorVersion, MinorVersion, 3, 2); };

                PollTimeoutRatio = 1000;
                ZmqMsgTSize = Zmq2MsgTSize;

                zmq_ctx_new = () => zmq_init(1);
                zmq_ctx_destroy = zmq_term;
            }
        }
コード例 #2
0
ファイル: LibZmq.NET.cs プロジェクト: ramesh-chip/clrzmq
 private static void AssignCommonDelegates()
 {
     zmq_init = NativeLib.GetUnmanagedFunction<ZmqInitProc>("zmq_init");
     zmq_term = NativeLib.GetUnmanagedFunction<ZmqTermProc>("zmq_term");
     zmq_close = NativeLib.GetUnmanagedFunction<ZmqCloseProc>("zmq_close");
     zmq_setsockopt = NativeLib.GetUnmanagedFunction<ZmqSetSockOptProc>("zmq_setsockopt");
     zmq_getsockopt = NativeLib.GetUnmanagedFunction<ZmqGetSockOptProc>("zmq_getsockopt");
     zmq_bind = NativeLib.GetUnmanagedFunction<ZmqBindProc>("zmq_bind");
     zmq_connect = NativeLib.GetUnmanagedFunction<ZmqConnectProc>("zmq_connect");
     zmq_socket = NativeLib.GetUnmanagedFunction<ZmqSocketProc>("zmq_socket");
     zmq_msg_close = NativeLib.GetUnmanagedFunction<ZmqMsgCloseProc>("zmq_msg_close");
     zmq_msg_copy = NativeLib.GetUnmanagedFunction<ZmqMsgCopyProc>("zmq_msg_copy");
     zmq_msg_data = NativeLib.GetUnmanagedFunction<ZmqMsgDataProc>("zmq_msg_data");
     zmq_msg_init = NativeLib.GetUnmanagedFunction<ZmqMsgInitProc>("zmq_msg_init");
     zmq_msg_init_size = NativeLib.GetUnmanagedFunction<ZmqMsgInitSizeProc>("zmq_msg_init_size");
     zmq_msg_size = NativeLib.GetUnmanagedFunction<ZmqMsgSizeProc>("zmq_msg_size");
     zmq_errno = NativeLib.GetUnmanagedFunction<ZmqErrnoProc>("zmq_errno");
     zmq_strerror = NativeLib.GetUnmanagedFunction<ZmqStrErrorProc>("zmq_strerror");
     zmq_version = NativeLib.GetUnmanagedFunction<ZmqVersionProc>("zmq_version");
     zmq_poll = NativeLib.GetUnmanagedFunction<ZmqPollProc>("zmq_poll");
 }
コード例 #3
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");

                var zmq_msg_recv_impl = NativeLib.GetUnmanagedFunction<ZmqMsgRecvProc>("zmq_msg_recv");
                zmq_msg_recv = zmq_msg_recv_impl;
                //used to receive raw buffer (rjoshi)
                var zmq_buffer_recv_impl = NativeLib.GetUnmanagedFunction<ZmqBufferRecvProc>("zmq_recv");
                zmq_buffer_recv = zmq_buffer_recv_impl;

                var zmq_msg_send_impl = NativeLib.GetUnmanagedFunction<ZmqMsgSendProc>("zmq_msg_send");
                zmq_msg_send = zmq_msg_send_impl;
                //used to send raw buffer (rjoshi)
                var zmq_buffer_send_impl = NativeLib.GetUnmanagedFunction<ZmqBufferSendProc>("zmq_send");
                zmq_buffer_send = zmq_buffer_send_impl;

                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_ctx_set_monitor = NativeLib.GetUnmanagedFunction<ZmqCtxSetMonitorProc>("zmq_ctx_set_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_send = (msg, sck, flags) => zmq_msg_send_impl(sck, msg, flags);
                zmq_msg_recv = (msg, sck, flags) => zmq_msg_recv_impl(sck, msg, flags);

                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;
            }
        }