SslStream.Write 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 스트림에 데이터를 씁니다.
오버로드
| Name | Description |
|---|---|
| Write(Byte[]) |
지정된 데이터를 이 스트림에 씁니다. |
| Write(ReadOnlySpan<Byte>) |
파생 클래스에서 재정의되는 경우 바이트 시퀀스를 현재 스트림에 쓰고 이 스트림 내의 현재 위치를 기록된 바이트 수만큼 앞으로 이동합니다. |
| Write(Byte[], Int32, Int32) |
지정된 버퍼 및 오프셋을 사용하여 기본 스트림에 지정된 수의 Bytes를 씁니다. |
Write(Byte[])
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
지정된 데이터를 이 스트림에 씁니다.
public:
void Write(cli::array <System::Byte> ^ buffer);
public void Write(byte[] buffer);
override this.Write : byte[] -> unit
Public Sub Write (buffer As Byte())
매개 변수
예외
buffer은 null입니다.
쓰기 작업이 실패했습니다.
이미 쓰기 작업이 진행 중입니다.
이 개체가 닫혔습니다.
인증이 발생하지 않았습니다.
예제
다음 코드 예제에서는 인증된 SslStream에 쓰는 방법을 보여 줍니다.
static void ProcessClient (TcpClient client)
{
// A client has connected. Create the
// SslStream using the client's network stream.
SslStream sslStream = new SslStream(
client.GetStream(), false);
// Authenticate the server but don't require the client to authenticate.
try
{
sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired: false, checkCertificateRevocation: true);
// Display the properties and settings for the authenticated stream.
DisplaySecurityLevel(sslStream);
DisplaySecurityServices(sslStream);
DisplayCertificateInformation(sslStream);
DisplayStreamProperties(sslStream);
// Set timeouts for the read and write to 5 seconds.
sslStream.ReadTimeout = 5000;
sslStream.WriteTimeout = 5000;
// Read a message from the client.
Console.WriteLine("Waiting for client message...");
string messageData = ReadMessage(sslStream);
Console.WriteLine("Received: {0}", messageData);
// Write a message to the client.
byte[] message = Encoding.UTF8.GetBytes("Hello from the server.<EOF>");
Console.WriteLine("Sending hello message.");
sslStream.Write(message);
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
if (e.InnerException != null)
{
Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
}
Console.WriteLine ("Authentication failed - closing the connection.");
sslStream.Close();
client.Close();
return;
}
finally
{
// The client stream will be closed with the sslStream
// because we specified this behavior when creating
// the sslStream.
sslStream.Close();
client.Close();
}
}
Private Shared Sub ProcessClient(client As TcpClient)
' A client has connected. Create the
' SslStream using the client's network stream.
Dim sslStream = New SslStream(client.GetStream(), False)
Try
sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired:=False, checkCertificateRevocation:=True)
' Display the properties And settings for the authenticated stream.
DisplaySecurityLevel(sslStream)
DisplaySecurityServices(sslStream)
DisplayCertificateInformation(sslStream)
DisplayStreamProperties(sslStream)
' Set timeouts for the read and write to 5 seconds.
sslStream.ReadTimeout = 5000
sslStream.WriteTimeout = 5000
' Read a message from the client.
Console.WriteLine("Waiting for client message...")
Dim messageData As String = ReadMessage(sslStream)
Console.WriteLine("Received: {0}", messageData)
' Write a message to the client.
Dim message As Byte() = Encoding.UTF8.GetBytes("Hello from the server.<EOF>")
Console.WriteLine("Sending hello message.")
sslStream.Write(message)
Catch e As AuthenticationException
Console.WriteLine("Exception: {0}", e.Message)
If e.InnerException IsNot Nothing Then
Console.WriteLine("Inner exception: {0}", e.InnerException.Message)
End If
Console.WriteLine("Authentication failed - closing the connection.")
sslStream.Close()
client.Close()
Return
Finally
' The client stream will be closed with the sslStream
' because we specified this behavior when creating
' the sslStream.
sslStream.Close()
client.Close()
End Try
End Sub
설명
이 메서드는 작업이 완료되는 동안 차단됩니다. 작업이 완료되는 동안 차단을 방지하려면 메서드를 BeginWrite 사용합니다.
성공적으로 인증될 때까지 이 메서드를 호출할 수 없습니다. 또는 , AuthenticateAsClientBeginAuthenticateAsClientAuthenticateAsServer 메서드 중 BeginAuthenticateAsServer하나를 호출하도록 인증합니다.
클래스는 SslStream 여러 동시 쓰기 작업을 지원하지 않습니다.
적용 대상
Write(ReadOnlySpan<Byte>)
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
파생 클래스에서 재정의되는 경우 바이트 시퀀스를 현재 스트림에 쓰고 이 스트림 내의 현재 위치를 기록된 바이트 수만큼 앞으로 이동합니다.
public:
override void Write(ReadOnlySpan<System::Byte> buffer);
public override void Write(ReadOnlySpan<byte> buffer);
override this.Write : ReadOnlySpan<byte> -> unit
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Byte))
매개 변수
- buffer
- ReadOnlySpan<Byte>
메모리 영역입니다. 이 메서드는 이 지역의 내용을 현재 스트림에 복사합니다.
적용 대상
Write(Byte[], Int32, Int32)
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
- Source:
- SslStream.cs
지정된 버퍼 및 오프셋을 사용하여 기본 스트림에 지정된 수의 Bytes를 씁니다.
public:
override void Write(cli::array <System::Byte> ^ buffer, int offset, int count);
public override void Write(byte[] buffer, int offset, int count);
override this.Write : byte[] * int * int -> unit
Public Overrides Sub Write (buffer As Byte(), offset As Integer, count As Integer)
매개 변수
예외
buffer은 null입니다.
쓰기 작업이 실패했습니다.
이미 쓰기 작업이 진행 중입니다.
이 개체가 닫혔습니다.
인증이 발생하지 않았습니다.
설명
이 메서드는 작업이 완료되는 동안 차단됩니다. 작업이 완료되는 동안 차단을 방지하려면 메서드를 BeginWrite 사용합니다.
성공적으로 인증될 때까지 이 메서드를 호출할 수 없습니다. 또는 , AuthenticateAsClientBeginAuthenticateAsClientAuthenticateAsServer 메서드 중 BeginAuthenticateAsServer하나를 호출하도록 인증합니다.
클래스는 SslStream 여러 동시 쓰기 작업을 지원하지 않습니다.