本文整理汇总了C#中SslStream.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# SslStream.Flush方法的具体用法?C# SslStream.Flush怎么用?C# SslStream.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SslStream
的用法示例。
在下文中一共展示了SslStream.Flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformTls
private void PerformTls()
{
// Create an SSL stream that will close the client's stream.
SecureStream = new SslStream(
Stream,
true,
new RemoteCertificateValidationCallback(ValidateServerCertificate));
// The server name must match the name on the server certificate.
try
{
SecureStream.AuthenticateAsClient(ServerName);
}
catch (AuthenticationException e)
{
Debug.LogError("Exception: " + e.Message);
if (e.InnerException != null)
{
Debug.LogError("Inner exception: " + e.InnerException.Message);
}
// Console.WriteLine("Authentication failed - closing the connection.");
Client.Close();
return;
}
// Authenticated!
string request = @"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='xmpp.livecoding.tv' version='1.0'>";
Debug.Log("Asking to open a new XMPP stream on authenticated SecureStream! " + request);
byte[] message = Encoding.UTF8.GetBytes(request);
// byte[] message = Convert.FromBase64String(@"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='xmpp.livecoding.tv' version='1.0'>");
// Set up new readers and writers.
SecureStream.Write(message);
SecureStream.Flush();
}
示例2: WriteJSONMessage
static void WriteJSONMessage(SslStream sslStream, JSONEvent eventObj)
{
string message = JsonConvert.SerializeObject(eventObj);
//Console.WriteLine(message);
byte[] msg = Encoding.UTF8.GetBytes(message);
sslStream.Write(msg);
sslStream.Flush();
}
示例3: SslStream_StreamToStream_Flush_Propagated
public void SslStream_StreamToStream_Flush_Propagated()
{
VirtualNetwork network = new VirtualNetwork();
using (var stream = new VirtualNetworkStream(network, isServer: false))
using (var sslStream = new SslStream(stream, false, AllowAnyServerCertificate))
{
Assert.False(stream.HasBeenSyncFlushed);
sslStream.Flush();
Assert.True(stream.HasBeenSyncFlushed);
}
}