本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}