当前位置: 首页>>代码示例>>C#>>正文


C# SslStream.ReadByte方法代码示例

本文整理汇总了C#中System.Net.Security.SslStream.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# SslStream.ReadByte方法的具体用法?C# SslStream.ReadByte怎么用?C# SslStream.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Security.SslStream的用法示例。


在下文中一共展示了SslStream.ReadByte方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadMessage

        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the client.
            // The client signals the end of the message using the
            // "" marker.
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                // Read the client's test message.
                bytes = sslStream.ReadByte();

                // Use Decoder class to convert from bytes to UTF8
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char znak = (char)bytes;
                messageData.Append(znak);
                // Check for EOF or an empty message.
                if (messageData.ToString().IndexOf("") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }
开发者ID:fxstar,项目名称:AsyncSslSocket,代码行数:26,代码来源:AsyncSslServer.cs

示例2: ssl_stream_with_client_certificates

        public void ssl_stream_with_client_certificates()
        {
            var net = new TestNetwork();

            var server = new Thread(
                () =>
                {
                    var ssl = new SslStream(net.Server, false, Validate);

                    ssl.AuthenticateAsServer(ServerCert, true, SslProtocols.Tls, false);

                     SslInfo("Server", ssl);

                    Assert.That(ssl.ReadByte() == 1);

                    ssl.WriteByte(2);
                });

            server.Start();

            var client = new Thread(
                () =>
                {
                    var ssl = new SslStream(net.Client, false, Validate, SelectCert);

                    ssl.AuthenticateAsClient("server.x", new X509CertificateCollection(new[] { ClientCert }), SslProtocols.Tls, false);

                    SslInfo("Client", ssl);

                    ssl.WriteByte(1);

                    Assert.That(ssl.ReadByte() == 2);
                });

            client.Start();

            server.Join();
            client.Join();
        }
开发者ID:bitdiff,项目名称:secular,代码行数:39,代码来源:SslTests.cs

示例3: streamReadLine

 private string streamReadLine(SslStream inputStream)
 {
     int next_char;
     string data = "";
     while (true) {
         next_char = inputStream.ReadByte();
         if (next_char == '\n') { break; }
         if (next_char == '\r') { continue; }
         if (next_char == -1) { Thread.Sleep(1); continue; };
         data += Convert.ToChar(next_char);
     }
     return data;
 }
开发者ID:quattrozhou,项目名称:paymentServer,代码行数:13,代码来源:paymentServer_connection.cs

示例4: readline

 /**
  * Internal method to read HTTP response header lines. Used by getHeader()
  */
 private string readline(SslStream s)
 {
     StringBuilder sb = new StringBuilder();
     Int32 i = 0;
     char c = (char)0;
     try
     {
         do
         {
             i = s.ReadByte();
             if (i == -1)
                 break;
             c = Convert.ToChar(i);
             if (c == '\n')
                 break;
             if (c != '\r')
                 sb.Append(c);
         }
         while (true);
     }
     catch (Exception e)
     {
         EventLog logger = new EventLog("Application");
         logger.Source = LOGSOURCE;
         StringBuilder sbe = new StringBuilder("Unexpected error ");
         sbe.Append(e.ToString());
         sbe.Append(" reading response header.");
         logger.WriteEntry(sbe.ToString(), EventLogEntryType.Error);
     }
     return sb.ToString();
 }
开发者ID:DamianJMurphy,项目名称:SpineTools-CSharp,代码行数:34,代码来源:ConnectionManager.cs


注:本文中的System.Net.Security.SslStream.ReadByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。