static WebSocketProtocolComponent()
        {
            s_DllFileName        = Path.Combine(Environment.SystemDirectory, WEBSOCKET);
            s_WebSocketDllHandle = SafeLoadLibrary.LoadLibraryEx(s_DllFileName);

            if (!s_WebSocketDllHandle.IsInvalid)
            {
                s_SupportedVersion = GetSupportedVersion();

                s_ServerFakeRequestHeaders = new HttpHeader[]
                {
                    new HttpHeader()
                    {
                        Name        = HttpKnownHeaderNames.Connection,
                        NameLength  = (uint)HttpKnownHeaderNames.Connection.Length,
                        Value       = HttpKnownHeaderNames.Upgrade,
                        ValueLength = (uint)HttpKnownHeaderNames.Upgrade.Length
                    },
                    new HttpHeader()
                    {
                        Name        = HttpKnownHeaderNames.Upgrade,
                        NameLength  = (uint)HttpKnownHeaderNames.Upgrade.Length,
                        Value       = WebSocketHelpers.WebSocketUpgradeToken,
                        ValueLength = (uint)WebSocketHelpers.WebSocketUpgradeToken.Length
                    },
                    new HttpHeader()
                    {
                        Name        = HttpKnownHeaderNames.Host,
                        NameLength  = (uint)HttpKnownHeaderNames.Host.Length,
                        Value       = string.Empty,
                        ValueLength = 0
                    },
                    new HttpHeader()
                    {
                        Name        = HttpKnownHeaderNames.SecWebSocketVersion,
                        NameLength  = (uint)HttpKnownHeaderNames.SecWebSocketVersion.Length,
                        Value       = s_SupportedVersion,
                        ValueLength = (uint)s_SupportedVersion.Length
                    },
                    new HttpHeader()
                    {
                        Name        = HttpKnownHeaderNames.SecWebSocketKey,
                        NameLength  = (uint)HttpKnownHeaderNames.SecWebSocketKey.Length,
                        Value       = s_DummyWebsocketKeyBase64,
                        ValueLength = (uint)s_DummyWebsocketKeyBase64.Length
                    }
                };
            }
        }
 static PeerToPeerOSHelper()
 {
     if (IsSupportedOS())
     {
         // if OS is supported, but p2p.dll is not available, P2P is not supported (original behavior)
         string dllFileName = Path.Combine(Environment.SystemDirectory, UnsafeP2PNativeMethods.P2P);
         s_P2PLibrary = SafeLoadLibrary.LoadLibraryEx(dllFileName);
         if (!s_P2PLibrary.IsInvalid)
         {
             IntPtr Address = UnsafeSystemNativeMethods.GetProcAddress(s_P2PLibrary, "PeerCreatePeerName");
             if (Address != IntPtr.Zero)
             {
                 s_supportsP2P = true;
             }
         }
     }
     //else --> the SafeLoadLibrary would have already been marked
     //          closed by the LoadLibraryEx call above.
 }
        static PeerToPeerOSHelper() {

            if (IsSupportedOS()) {

                // if OS is supported, but p2p.dll is not available, P2P is not supported (original behavior)
                string dllFileName = Path.Combine(Environment.SystemDirectory, UnsafeP2PNativeMethods.P2P);
                s_P2PLibrary = SafeLoadLibrary.LoadLibraryEx(dllFileName);
                if (!s_P2PLibrary.IsInvalid) {
                    IntPtr Address = UnsafeSystemNativeMethods.GetProcAddress(s_P2PLibrary, "PeerCreatePeerName");
                    if (Address != IntPtr.Zero) {
                        s_supportsP2P = true;
                    }
                }
            }
            //else --> the SafeLoadLibrary would have already been marked
            //          closed by the LoadLibraryEx call above.
        }
        static WebSocketProtocolComponent()
        {
            s_DllFileName = Path.Combine(Environment.SystemDirectory, WEBSOCKET);
            s_WebSocketDllHandle = SafeLoadLibrary.LoadLibraryEx(s_DllFileName);

            if (!s_WebSocketDllHandle.IsInvalid)
            {
                s_SupportedVersion = GetSupportedVersion();

                s_ServerFakeRequestHeaders = new HttpHeader[] 
                {
                    new HttpHeader()
                    { 
                        Name = HttpKnownHeaderNames.Connection, 
                        NameLength = (uint)HttpKnownHeaderNames.Connection.Length, 
                        Value = HttpKnownHeaderNames.Upgrade, 
                        ValueLength = (uint)HttpKnownHeaderNames.Upgrade.Length 
                    },
                    new HttpHeader()
                    { 
                        Name = HttpKnownHeaderNames.Upgrade, 
                        NameLength = (uint)HttpKnownHeaderNames.Upgrade.Length, 
                        Value = WebSocketHelpers.WebSocketUpgradeToken, 
                        ValueLength = (uint)WebSocketHelpers.WebSocketUpgradeToken.Length 
                    },
                    new HttpHeader()
                    { 
                        Name = HttpKnownHeaderNames.Host, 
                        NameLength = (uint)HttpKnownHeaderNames.Host.Length, 
                        Value = string.Empty, 
                        ValueLength = 0 
                    },
                    new HttpHeader()
                    { 
                        Name = HttpKnownHeaderNames.SecWebSocketVersion, 
                        NameLength = (uint)HttpKnownHeaderNames.SecWebSocketVersion.Length, 
                        Value = s_SupportedVersion, 
                        ValueLength = (uint)s_SupportedVersion.Length 
                    },
                    new HttpHeader()
                    { 
                        Name = HttpKnownHeaderNames.SecWebSocketKey, 
                        NameLength = (uint)HttpKnownHeaderNames.SecWebSocketKey.Length, 
                        Value = s_DummyWebsocketKeyBase64, 
                        ValueLength = (uint)s_DummyWebsocketKeyBase64.Length 
                    }
                };
            }
        }