For selecting on NetMQSocket or regualr .net Socket. This is for advanced usages, for most cases NetMQPoller is the suggested alternative.
Пример #1
0
 internal NetMQSocket(SocketBase socketHandle)
 {
     m_netMqSelector   = new NetMQSelector();
     m_socketHandle    = socketHandle;
     Options           = new SocketOptions(this);
     m_socketEventArgs = new NetMQSocketEventArgs(this);
 }
Пример #2
0
        internal NetMQSocket(ZmqSocketType socketType, string?connectionString, DefaultAction defaultAction)
        {
            m_socketHandle    = NetMQConfig.Context.CreateSocket(socketType);
            m_netMqSelector   = new NetMQSelector();
            Options           = new SocketOptions(this);
            m_socketEventArgs = new NetMQSocketEventArgs(this);

            Options.Linger = NetMQConfig.Linger;

            if (!Strings.IsNullOrEmpty(connectionString))
            {
                var endpoints = connectionString
                                .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                .Select(a => a.Trim())
                                .Where(a => !string.IsNullOrEmpty(a));

                foreach (var endpoint in endpoints)
                {
                    switch (endpoint[0])
                    {
                    case '@':
                        Bind(endpoint.Substring(1));
                        break;

                    case '>':
                        Connect(endpoint.Substring(1));
                        break;

                    default:
                        if (defaultAction == DefaultAction.Connect)
                        {
                            Connect(endpoint);
                        }
                        else
                        {
                            Bind(endpoint);
                        }
                        break;
                    }
                }
            }
        }