SslStream::Flush Method ()
.NET Framework (current version)
Causes any buffered data to be written to the underlying device.
Assembly: System (in System.dll)
The following code example demonstrates calling this method.
// Create a TCP/IP client socket. // machineName is the host running the server application. TcpClient^ client = gcnew TcpClient(machineName, 8080); Console::WriteLine("Client connected."); // Create an SSL stream that will close // the client's stream. SslStream^ sslStream = gcnew SslStream( client->GetStream(), false, gcnew RemoteCertificateValidationCallback(ValidateServerCertificate), nullptr); // The server name must match the name // on the server certificate. try { sslStream->AuthenticateAsClient(serverName); } catch (AuthenticationException^ ex) { Console::WriteLine("Exception: {0}", ex->Message); if (ex->InnerException != nullptr) { Console::WriteLine("Inner exception: {0}", ex->InnerException->Message); } Console::WriteLine("Authentication failed - " "closing the connection."); sslStream->Close(); client->Close(); return; } // Encode a test message into a byte array. // Signal the end of the message using the "<EOF>". array<Byte>^ messsage = Encoding::UTF8->GetBytes( "Hello from the client.<EOF>"); // Send hello message to the server. sslStream->Write(messsage); sslStream->Flush();
.NET Framework
Available since 2.0
Available since 2.0
Show: