AnonymousPipeServerStream 클래스

정의

동기 및 비동기 읽기/쓰기 작업을 모두 지원하는 익명 파이프 주위의 스트림을 노출합니다.

public ref class AnonymousPipeServerStream sealed : System::IO::Pipes::PipeStream
public sealed class AnonymousPipeServerStream : System.IO.Pipes.PipeStream
type AnonymousPipeServerStream = class
    inherit PipeStream
Public NotInheritable Class AnonymousPipeServerStream
Inherits PipeStream
상속
AnonymousPipeServerStream
상속
AnonymousPipeServerStream

예제

다음 예제에서는 익명 파이프를 사용하여 부모 프로세스에서 자식 프로세스로 문자열을 보냅니다. 이 예제에서는 값이 인 AnonymousPipeServerStream 부모 프로세스에서 개체를 PipeDirection 만듭니PipeDirection.Out다. 또한 값PipeDirection.In이 인 AnonymousPipeClientStream 자식 프로세스에서 개체를 PipeDirection 만듭니다. 그런 다음, 부모 프로세스는 사용자가 제공한 문자열을 자식 프로세스로 보냅니다. 문자열이 콘솔에 표시됩니다.

이 예제는 클래스를 사용하는 서버 프로세스에 대한 AnonymousPipeServerStream 것입니다. 파이프 클라이언트와 서버 모두에 대한 코드를 포함한 전체 코드 예제는 방법: 로컬 프로세스 간 통신에 익명 파이프 사용을 참조하세요.

//<snippet01>
#using <System.dll>
#using <System.Core.dll>

using namespace System;
using namespace System::IO;
using namespace System::IO::Pipes;
using namespace System::Diagnostics;

ref class PipeServer
{
public:
    static void Main()
    {
        Process^ pipeClient = gcnew Process();

        pipeClient->StartInfo->FileName = "pipeClient.exe";

        AnonymousPipeServerStream^ pipeServer =
            gcnew AnonymousPipeServerStream(PipeDirection::Out,
            HandleInheritability::Inheritable);

        Console::WriteLine("[SERVER] Current TransmissionMode: {0}.",
            pipeServer->TransmissionMode);

        // Pass the client process a handle to the server.
        pipeClient->StartInfo->Arguments =
            pipeServer->GetClientHandleAsString();
        pipeClient->StartInfo->UseShellExecute = false;
        pipeClient->Start();

        pipeServer->DisposeLocalCopyOfClientHandle();

        try
        {
            // Read user input and send that to the client process.
            StreamWriter^ sw = gcnew StreamWriter(pipeServer);

            sw->AutoFlush = true;
            // Send a 'sync message' and wait for client to receive it.
            sw->WriteLine("SYNC");
            pipeServer->WaitForPipeDrain();
            // Send the console input to the client process.
            Console::Write("[SERVER] Enter text: ");
            sw->WriteLine(Console::ReadLine());
            sw->Close();
        }
        // Catch the IOException that is raised if the pipe is broken
        // or disconnected.
        catch (IOException^ e)
        {
            Console::WriteLine("[SERVER] Error: {0}", e->Message);
        }
        pipeServer->Close();
        pipeClient->WaitForExit();
        pipeClient->Close();
        Console::WriteLine("[SERVER] Client quit. Server terminating.");
    }
};

int main()
{
    PipeServer::Main();
}
//</snippet01>
//<snippet01>
using System;
using System.IO;
using System.IO.Pipes;
using System.Diagnostics;

class PipeServer
{
    static void Main()
    {
        Process pipeClient = new Process();

        pipeClient.StartInfo.FileName = "pipeClient.exe";

        using (AnonymousPipeServerStream pipeServer =
            new AnonymousPipeServerStream(PipeDirection.Out,
            HandleInheritability.Inheritable))
        {
            Console.WriteLine("[SERVER] Current TransmissionMode: {0}.",
                pipeServer.TransmissionMode);

            // Pass the client process a handle to the server.
            pipeClient.StartInfo.Arguments =
                pipeServer.GetClientHandleAsString();
            pipeClient.StartInfo.UseShellExecute = false;
            pipeClient.Start();

            pipeServer.DisposeLocalCopyOfClientHandle();

            try
            {
                // Read user input and send that to the client process.
                using (StreamWriter sw = new StreamWriter(pipeServer))
                {
                    sw.AutoFlush = true;
                    // Send a 'sync message' and wait for client to receive it.
                    sw.WriteLine("SYNC");
                    pipeServer.WaitForPipeDrain();
                    // Send the console input to the client process.
                    Console.Write("[SERVER] Enter text: ");
                    sw.WriteLine(Console.ReadLine());
                }
            }
            // Catch the IOException that is raised if the pipe is broken
            // or disconnected.
            catch (IOException e)
            {
                Console.WriteLine("[SERVER] Error: {0}", e.Message);
            }
        }

        pipeClient.WaitForExit();
        pipeClient.Close();
        Console.WriteLine("[SERVER] Client quit. Server terminating.");
    }
}
//</snippet01>
'<snippet01>
Imports System.IO
Imports System.IO.Pipes
Imports System.Diagnostics

Class PipeServer
    Shared Sub Main()
        Dim pipeClient As New Process()

        pipeClient.StartInfo.FileName = "pipeClient.exe"

        Using pipeServer As New AnonymousPipeServerStream(PipeDirection.Out, _
            HandleInheritability.Inheritable)

            Console.WriteLine("[SERVER] Current TransmissionMode: {0}.",
                pipeServer.TransmissionMode)

            ' Pass the client process a handle to the server.
            pipeClient.StartInfo.Arguments = pipeServer.GetClientHandleAsString()
            pipeClient.StartInfo.UseShellExecute = false
            pipeClient.Start()

            pipeServer.DisposeLocalCopyOfClientHandle()

            Try
                ' Read user input and send that to the client process.
                Using sw As New StreamWriter(pipeServer)
                    sw.AutoFlush = true
                    ' Send a 'sync message' and wait for client to receive it.
                    sw.WriteLine("SYNC")
                    pipeServer.WaitForPipeDrain()
                    ' Send the console input to the client process.
                    Console.Write("[SERVER] Enter text: ")
                    sw.WriteLine(Console.ReadLine())
                End Using
            Catch e As IOException
                ' Catch the IOException that is raised if the pipe is broken
                ' or disconnected.
                Console.WriteLine("[SERVER] Error: {0}", e.Message)
            End Try
        End Using

        pipeClient.WaitForExit()
        pipeClient.Close()
        Console.WriteLine("[SERVER] Client quit. Server terminating.")
    End Sub
End Class
'</snippet01>

설명

익명 파이프는 자식 프로세스와 부모 프로세스 간에 안전하고 안전한 프로세스 간 통신을 제공하는 데 도움이 됩니다. AnonymousPipeServerStream 클래스를 사용하면 부모 프로세스가 자식 프로세스에서 정보를 보내거나 받을 수 있습니다.

익명 파이프는 일반적으로 부모 프로세스와 자식 프로세스 간에 데이터를 전송하는 명명되지 않은 단방향 파이프입니다. 익명 파이프는 항상 로컬입니다. 네트워크를 통해 사용할 수 없습니다. PipeDirection 익명 파이프가 단방향으로 정의되므로 값 InOut 은 지원되지 않습니다.

익명 파이프는 읽기 모드를 PipeTransmissionMode.Message 지원하지 않습니다.

익명 파이프의 클라이언트 쪽은 메서드를 호출 GetClientHandleAsString 하여 서버 쪽에서 제공하는 파이프 핸들에서 만들어야 합니다. 그런 다음 클라이언트 프로세스를 만들 때 문자열이 매개 변수로 전달됩니다. 클라이언트 프로세스에서 매개 변수로 pipeHandleAsString 생성자에 전달 AnonymousPipeClientStream 됩니다.

개체는 AnonymousPipeServerStream 클라이언트가 종료될 때 알림을 받도록 메서드를 DisposeLocalCopyOfClientHandle 사용하여 클라이언트 핸들을 삭제해야 합니다.

생성자

AnonymousPipeServerStream()

AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

AnonymousPipeServerStream(PipeDirection)

지정된 파이프 방향을 사용하여 AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

AnonymousPipeServerStream(PipeDirection, HandleInheritability)

지정된 파이프 방향 및 상속 모드를 사용하여 AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32)

지정된 파이프 방향, 상속 모드 및 버퍼 크기를 사용하여 AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32, PipeSecurity)

지정된 파이프 방향, 상속 모드, 버퍼 크기 및 파이프 보안을 사용하여 AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

AnonymousPipeServerStream(PipeDirection, SafePipeHandle, SafePipeHandle)

지정된 파이프 핸들을 사용하여 AnonymousPipeServerStream 클래스의 새 인스턴스를 초기화합니다.

속성

CanRead

현재 스트림이 읽기 작업을 지원하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
CanSeek

현재 스트림이 검색 작업을 지원하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
CanTimeout

현재 스트림이 시간 초과될 수 있는지를 결정하는 값을 가져옵니다.

(다음에서 상속됨 Stream)
CanWrite

현재 스트림이 쓰기 작업을 지원하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
ClientSafePipeHandle

현재 AnonymousPipeClientStream 개체에 연결된 AnonymousPipeServerStream 개체에 대한 안전한 핸들을 가져옵니다.

InBufferSize

파이프에 대한 인바운드 버퍼의 크기(바이트 단위)를 가져옵니다.

(다음에서 상속됨 PipeStream)
IsAsync

PipeStream 개체가 동기적으로 열렸는지 비동기적으로 열렸는지 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
IsConnected

PipeStream 개체가 연결되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 PipeStream)
IsHandleExposed

PipeStream 개체에 대한 핸들이 노출되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
IsMessageComplete

가장 최근의 읽기 작업을 통해 반환된 메시지에 다른 데이터가 더 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 PipeStream)
Length

스트림의 길이(바이트 단위)를 가져옵니다.

(다음에서 상속됨 PipeStream)
OutBufferSize

파이프에 대한 아웃바운드 버퍼의 크기(바이트 단위)를 가져옵니다.

(다음에서 상속됨 PipeStream)
Position

현재 스트림의 현재 위치를 가져오거나 설정합니다.

(다음에서 상속됨 PipeStream)
ReadMode

AnonymousPipeServerStream 개체에 대한 읽기 모드를 설정합니다. 익명 파이프의 경우 전송 모드가 Byte여야 합니다.

ReadTimeout

스트림 읽기 시도가 만료되기 전까지 기다릴 시간을 결정하는 값(밀리초)을 가져오거나 설정합니다.

(다음에서 상속됨 Stream)
SafePipeHandle

현재 PipeStream 개체에서 캡슐화하는 파이프의 로컬 끝에 대한 SafeHandle을 가져옵니다.

(다음에서 상속됨 PipeStream)
TransmissionMode

현재 파이프가 지원하는 파이프 전송 모드를 가져옵니다.

WriteTimeout

스트림 쓰기 시도가 만료되기 전까지 기다릴 시간을 결정하는 값(밀리초)을 가져오거나 설정합니다.

(다음에서 상속됨 Stream)

메서드

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

비동기 읽기 작업을 시작합니다.

(다음에서 상속됨 PipeStream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

비동기 쓰기 작업을 시작합니다.

(다음에서 상속됨 PipeStream)
CheckPipePropertyOperations()

파이프가 속성을 가져오거나 설정할 수 있는 적절한 상태인지 확인합니다.

(다음에서 상속됨 PipeStream)
CheckReadOperations()

파이프가 읽기 작업을 위해 연결된 상태인지 확인합니다.

(다음에서 상속됨 PipeStream)
CheckWriteOperations()

파이프가 쓰기 작업을 위해 연결된 상태인지 확인합니다.

(다음에서 상속됨 PipeStream)
Close()

현재 스트림을 닫고 현재 스트림과 관련된 소켓과 파일 핸들 등의 리소스를 모두 해제합니다. 이 메서드를 호출하는 대신 스트림이 올바르게 삭제되었는지 확인합니다.

(다음에서 상속됨 Stream)
CopyTo(Stream)

현재 스트림에서 바이트를 읽어서 다른 스트림에 해당 바이트를 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyTo(Stream, Int32)

현재 스트림에서 바이트를 읽어서 지정된 버퍼 크기로 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream)

현재 스트림에서 모든 바이트를 비동기적으로 읽어 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 취소 토큰을 사용하여 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 버퍼 크기로 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 버퍼 크기 및 취소 토큰을 사용하여 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
CreateWaitHandle()
사용되지 않음.
사용되지 않음.
사용되지 않음.

WaitHandle 개체를 할당합니다.

(다음에서 상속됨 Stream)
Dispose()

Stream에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Stream)
Dispose(Boolean)

PipeStream 클래스에 사용되는 관리되지 않는 리소스를 해제하고, 필요에 따라 관리되는 리소스를 해제합니다.

(다음에서 상속됨 PipeStream)
DisposeAsync()

Stream에서 사용하는 관리되지 않는 리소스를 비동기적으로 해제합니다.

(다음에서 상속됨 Stream)
DisposeLocalCopyOfClientHandle()

AnonymousPipeClientStream 개체 핸들의 로컬 복사본을 종료합니다.

EndRead(IAsyncResult)

보류 중인 비동기 읽기 요청을 끝냅니다.

(다음에서 상속됨 PipeStream)
EndWrite(IAsyncResult)

보류 중인 비동기 쓰기 요청을 끝냅니다.

(다음에서 상속됨 PipeStream)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Finalize()

가비지 컬렉션에 의해 AnonymousPipeServerStream 인스턴스가 회수되기 전에 관리되지 않는 리소스를 해제하고 기타 정리 작업을 수행합니다.

Flush()

현재 스트림에 대한 버퍼를 지우고 버퍼링된 모든 데이터를 내부 디바이스에 기록합니다.

(다음에서 상속됨 PipeStream)
FlushAsync()

이 스트림에 대한 모든 버퍼를 비동기적으로 지우고 버퍼링된 모든 데이터가 내부 디바이스에 비동기적으로 쓰여지도록 합니다.

(다음에서 상속됨 Stream)
FlushAsync(CancellationToken)

비동기적으로 현재 스트림에 대한 버퍼를 지우고 버퍼링된 모든 데이터를 내부 디바이스에 기록합니다.

(다음에서 상속됨 PipeStream)
GetAccessControl()

현재 PipeSecurity 개체에서 설명하는 파이프의 ACL(액세스 제어 목록) 엔트리를 캡슐화하는 PipeStream 개체를 가져옵니다.

(다음에서 상속됨 PipeStream)
GetClientHandleAsString()

연결된 AnonymousPipeClientStream 개체의 핸들을 문자열로 가져옵니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeHandle(SafePipeHandle, Boolean, Boolean)

지정된 PipeStream 개체에서 SafePipeHandle 개체를 초기화합니다.

(다음에서 상속됨 PipeStream)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ObjectInvariant()
사용되지 않음.

Contract에 대한 지원을 제공합니다.

(다음에서 상속됨 Stream)
Read(Byte[], Int32, Int32)

스트림에서 바이트 블록을 읽고 지정된 길이에 대해 지정된 위치에서 시작하는 지정 버퍼에 데이터를 씁니다.

(다음에서 상속됨 PipeStream)
Read(Span<Byte>)

현재 스트림에서 바이트 시퀀스를 읽고, 이를 바이트 배열에 쓰고, 읽은 바이트 수만큼 스트림에서 위치를 앞으로 이동합니다.

(다음에서 상속됨 PipeStream)
ReadAsync(Byte[], Int32, Int32)

현재 스트림에서 바이트 시퀀스를 읽고 읽은 바이트 수만큼 스트림에서 위치를 비동기적으로 앞으로 이동합니다.

(다음에서 상속됨 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

현재 스트림에서 지정된 바이트 수에 대해 지정된 위치에서 시작하는 바이트 배열까지 바이트의 시퀀스를 비동기적으로 읽고, 읽은 바이트 수만큼 스트림 내에서 앞으로 이동하며, 취소 요청을 모니터링합니다.

(다음에서 상속됨 PipeStream)
ReadAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트의 시퀀스를 비동기적으로 읽고, 이를 바이트 메모리 범위에 쓰고, 읽은 바이트 수만큼 스트림 내에서 앞으로 이동하며, 취소 요청을 모니터링합니다.

(다음에서 상속됨 PipeStream)
ReadAtLeast(Span<Byte>, Int32, Boolean)

현재 스트림에서 최소 바이트 수를 읽고 읽은 바이트 수만큼 스트림 내의 위치를 진행합니다.

(다음에서 상속됨 Stream)
ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)

현재 스트림에서 최소 바이트 수를 비동기적으로 읽고, 스트림 내의 위치를 읽은 바이트 수만큼 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadByte()

파이프에서 바이트를 읽습니다.

(다음에서 상속됨 PipeStream)
ReadExactly(Byte[], Int32, Int32)

count 현재 스트림에서 바이트 수를 읽고 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactly(Span<Byte>)

현재 스트림에서 바이트를 읽고 가 채워질 때까지 buffer 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)

현재 스트림에서 바이트 수를 비동기적으로 읽고 count , 스트림 내의 위치를 확장하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽고, 가 채워질 때까지 buffer 스트림 내의 위치를 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
Seek(Int64, SeekOrigin)

현재 스트림의 현재 위치를 지정된 값으로 설정합니다.

(다음에서 상속됨 PipeStream)
SetAccessControl(PipeSecurity)

PipeSecurity 개체에서 지정한 ACL(액세스 제어 목록) 엔트리를 현재 PipeStream 개체에 지정된 파이프에 적용합니다.

(다음에서 상속됨 PipeStream)
SetLength(Int64)

현재 스트림의 길이를 지정된 값으로 설정합니다.

(다음에서 상속됨 PipeStream)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
WaitForPipeDrain()

전달된 바이트를 파이프의 다른 끝에서 모두 읽을 때까지 기다립니다.

(다음에서 상속됨 PipeStream)
Write(Byte[], Int32, Int32)

버퍼의 데이터를 사용하여 현재 스트림에 바이트 블록을 씁니다.

(다음에서 상속됨 PipeStream)
Write(ReadOnlySpan<Byte>)

현재 스트림에 바이트 시퀀스를 쓰고 쓴 바이트 수만큼 이 스트림에서 현재 위치를 앞으로 이동합니다.

(다음에서 상속됨 PipeStream)
WriteAsync(Byte[], Int32, Int32)

현재 스트림에 바이트 시퀀스를 비동기적으로 쓰고 쓴 바이트 수만큼 이 스트림에서 현재 위치를 앞으로 이동합니다.

(다음에서 상속됨 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

지정된 위치에서 시작하는 바이트 배열에서 지정된 바이트 수를 비동기적으로 쓰고, 쓴 바이트 수만큼 이 스트림 내의 현재 위치를 앞으로 이동하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 PipeStream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

바이트의 시퀀스를 현재 스트림에 비동기적으로 쓰고 쓰여진 바이트 수만큼 이 스트림 내의 현재 위치를 앞으로 이동한 후 취소 요청을 모니터링합니다.

(다음에서 상속됨 PipeStream)
WriteByte(Byte)

현재 스트림에 바이트를 씁니다.

(다음에서 상속됨 PipeStream)

확장 메서드

CopyToAsync(Stream, PipeWriter, CancellationToken)

Stream의 바이트를 비동기식으로 읽고 취소 토큰을 사용하여 지정된 PipeWriter에 씁니다.

GetAccessControl(PipeStream)

파이프 스트림의 보안 정보를 반환합니다.

SetAccessControl(PipeStream, PipeSecurity)

기존 파이프 스트림의 보안 특성을 변경합니다.

ConfigureAwait(IAsyncDisposable, Boolean)

비동기 일회용에서 반환되는 작업을 대기하는 방법을 구성합니다.

적용 대상