NetMQ.Core.Transports.Pgm.PgmSocket.Init C# (CSharp) Method

Init() private method

Perform initialization of this PgmSocket, including creating the socket handle.
private Init ( ) : void
return void
        internal void Init()
        {
#if DEBUG
            // Don't want to bloat the code with excessive debugging information, unless this is a DEBUG build.  jh
            try
            {
#endif
                Handle = AsyncSocket.Create(AddressFamily.InterNetwork, SocketType.Rdm, PgmProtocolType);
#if DEBUG
            }
            catch (SocketException x)
            {
                string xMsg = string.Format("SocketException with ErrorCode={0}, SocketErrorCode={1}, Message={2}, in PgmSocket.Init, within AsyncSocket.Create(AddressFamily.InterNetwork, SocketType.Rdm, PGM_PROTOCOL_TYPE), {3}", x.ErrorCode, x.SocketErrorCode, x.Message, this);
                Debug.WriteLine(xMsg);
                // If running on Microsoft Windows, suggest to the developer that he may need to install MSMQ in order to get PGM socket support.
                PlatformID p = Environment.OSVersion.Platform;
                bool isWindows = true;
                switch (p)
                {
                    case PlatformID.Win32NT:
                        break;
                    case PlatformID.Win32S:
                        break;
                    case PlatformID.Win32Windows:
                        break;
                    default:
                        isWindows = false;
                        break;
                }
                if (isWindows)
                {
                    Debug.WriteLine("For Microsoft Windows, you may want to check to see whether you have installed MSMQ on this host, to get PGM socket support.");
                }
                throw new FaultException(innerException: x, message: xMsg);
            }
#endif
            Handle.ExclusiveAddressUse = false;
            Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
        }

Usage Example

示例#1
0
        private void Accept()
        {
            m_acceptedSocket = new PgmSocket(m_options, PgmSocketType.Receiver, m_address);
            m_acceptedSocket.Init();

            m_handle.Accept(m_acceptedSocket.Handle);
        }
All Usage Examples Of NetMQ.Core.Transports.Pgm.PgmSocket::Init