Поделиться через


AnonymousPipeServerStream Конструкторы

Определение

Инициализирует новый экземпляр класса AnonymousPipeServerStream.

Перегрузки

AnonymousPipeServerStream()

Инициализирует новый экземпляр класса AnonymousPipeServerStream.

AnonymousPipeServerStream(PipeDirection)

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала.

AnonymousPipeServerStream(PipeDirection, HandleInheritability)

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала и режимом наследования.

AnonymousPipeServerStream(PipeDirection, SafePipeHandle, SafePipeHandle)

Инициализирует новый экземпляр класса AnonymousPipeServerStream на основе указанного дескриптора канала.

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32)

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала, режимом наследования и размером буфера.

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32, PipeSecurity)

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала, режимом наследования, размером буфера и режимом безопасности канала.

AnonymousPipeServerStream()

Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs

Инициализирует новый экземпляр класса AnonymousPipeServerStream.

public:
 AnonymousPipeServerStream();
public AnonymousPipeServerStream ();
Public Sub New ()

Комментарии

Для AnonymousPipeServerStream конструкторов без PipeDirection параметра направление по умолчанию — Out. Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Этот конструктор создает AnonymousPipeServerStream объект с размером буфера по умолчанию, без безопасности канала и значением HandleInheritabilityNone.

Применяется к

AnonymousPipeServerStream(PipeDirection)

Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала.

public:
 AnonymousPipeServerStream(System::IO::Pipes::PipeDirection direction);
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction);
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection -> System.IO.Pipes.AnonymousPipeServerStream
Public Sub New (direction As PipeDirection)

Параметры

direction
PipeDirection

Одно из значений перечисления, определяющее направление канала.

Данные в анонимных каналах могут передаваться только в одном направлении, поэтому для параметра direction нельзя задать значение InOut.

Исключения

Параметру direction задается значение InOut.

Комментарии

Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Этот конструктор создает AnonymousPipeServerStream объект с размером буфера по умолчанию, без безопасности канала и значением HandleInheritabilityNone.

Применяется к

AnonymousPipeServerStream(PipeDirection, HandleInheritability)

Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала и режимом наследования.

public:
 AnonymousPipeServerStream(System::IO::Pipes::PipeDirection direction, System::IO::HandleInheritability inheritability);
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability);
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * System.IO.HandleInheritability -> System.IO.Pipes.AnonymousPipeServerStream
Public Sub New (direction As PipeDirection, inheritability As HandleInheritability)

Параметры

direction
PipeDirection

Одно из значений перечисления, определяющее направление канала.

Данные в анонимных каналах могут передаваться только в одном направлении, поэтому для параметра direction нельзя задать значение InOut.

inheritability
HandleInheritability

Одно из значений перечисления, определяющее, может ли базовый дескриптор наследоваться дочерними процессами. Возможные значения: None или Inheritable.

Исключения

Параметру inheritability не присвоено значение None или Inheritable.

Параметру direction задается значение InOut.

Примеры

В следующем примере демонстрируется метод для отправки строки из родительского процесса в дочерний процесс с помощью анонимных каналов. В этом примере AnonymousPipeServerStream объект создается в родительском процессе со значением PipeDirectionOut.

//<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>

Комментарии

Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Этот конструктор создает AnonymousPipeServerStream объект с размером буфера по умолчанию и без безопасности канала.

Применяется к

AnonymousPipeServerStream(PipeDirection, SafePipeHandle, SafePipeHandle)

Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs

Инициализирует новый экземпляр класса AnonymousPipeServerStream на основе указанного дескриптора канала.

public:
 AnonymousPipeServerStream(System::IO::Pipes::PipeDirection direction, Microsoft::Win32::SafeHandles::SafePipeHandle ^ serverSafePipeHandle, Microsoft::Win32::SafeHandles::SafePipeHandle ^ clientSafePipeHandle);
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, Microsoft.Win32.SafeHandles.SafePipeHandle serverSafePipeHandle, Microsoft.Win32.SafeHandles.SafePipeHandle clientSafePipeHandle);
[System.Security.SecurityCritical]
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, Microsoft.Win32.SafeHandles.SafePipeHandle serverSafePipeHandle, Microsoft.Win32.SafeHandles.SafePipeHandle clientSafePipeHandle);
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * Microsoft.Win32.SafeHandles.SafePipeHandle * Microsoft.Win32.SafeHandles.SafePipeHandle -> System.IO.Pipes.AnonymousPipeServerStream
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * Microsoft.Win32.SafeHandles.SafePipeHandle * Microsoft.Win32.SafeHandles.SafePipeHandle -> System.IO.Pipes.AnonymousPipeServerStream
Public Sub New (direction As PipeDirection, serverSafePipeHandle As SafePipeHandle, clientSafePipeHandle As SafePipeHandle)

Параметры

direction
PipeDirection

Одно из значений перечисления, определяющее направление канала.

Данные в анонимных каналах могут передаваться только в одном направлении, поэтому для параметра direction нельзя задать значение InOut.

serverSafePipeHandle
SafePipeHandle

Безопасный дескриптор для канала, который будет инкапсулироваться данным объектом AnonymousPipeServerStream.

clientSafePipeHandle
SafePipeHandle

Безопасный дескриптор для объекта AnonymousPipeClientStream.

Атрибуты

Исключения

serverSafePipeHandle или clientSafePipeHandle является недопустимым дескриптором.

Параметр serverSafePipeHandle или clientSafePipeHandle имеет значение null.

Параметру direction задается значение InOut.

Произошла ошибка ввода-вывода, например ошибка диска.

-или-

Поток закрыт.

Комментарии

Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Применяется к

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32)

Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs
Исходный код:
AnonymousPipeServerStream.cs

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала, режимом наследования и размером буфера.

public:
 AnonymousPipeServerStream(System::IO::Pipes::PipeDirection direction, System::IO::HandleInheritability inheritability, int bufferSize);
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, int bufferSize);
[System.Security.SecurityCritical]
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, int bufferSize);
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * System.IO.HandleInheritability * int -> System.IO.Pipes.AnonymousPipeServerStream
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * System.IO.HandleInheritability * int -> System.IO.Pipes.AnonymousPipeServerStream
Public Sub New (direction As PipeDirection, inheritability As HandleInheritability, bufferSize As Integer)

Параметры

direction
PipeDirection

Одно из значений перечисления, определяющее направление канала.

Данные в анонимных каналах могут передаваться только в одном направлении, поэтому для параметра direction нельзя задать значение InOut.

inheritability
HandleInheritability

Одно из значений перечисления, определяющее, может ли базовый дескриптор наследоваться дочерними процессами. Возможные значения: None или Inheritable.

bufferSize
Int32

Размер буфера. Это значение должно быть больше или равно 0.

Атрибуты

Исключения

Параметру inheritability не присвоено значение None или Inheritable.

-или-

Значение параметраbufferSize меньше 0.

Параметру direction задается значение InOut.

Комментарии

Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Этот конструктор создает AnonymousPipeServerStream объект без безопасности канала.

Применяется к

AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32, PipeSecurity)

Инициализирует новый экземпляр класса AnonymousPipeServerStream с указанным направлением канала, режимом наследования, размером буфера и режимом безопасности канала.

public:
 AnonymousPipeServerStream(System::IO::Pipes::PipeDirection direction, System::IO::HandleInheritability inheritability, int bufferSize, System::IO::Pipes::PipeSecurity ^ pipeSecurity);
[System.Security.SecurityCritical]
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, int bufferSize, System.IO.Pipes.PipeSecurity pipeSecurity);
public AnonymousPipeServerStream (System.IO.Pipes.PipeDirection direction, System.IO.HandleInheritability inheritability, int bufferSize, System.IO.Pipes.PipeSecurity pipeSecurity);
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * System.IO.HandleInheritability * int * System.IO.Pipes.PipeSecurity -> System.IO.Pipes.AnonymousPipeServerStream
new System.IO.Pipes.AnonymousPipeServerStream : System.IO.Pipes.PipeDirection * System.IO.HandleInheritability * int * System.IO.Pipes.PipeSecurity -> System.IO.Pipes.AnonymousPipeServerStream
Public Sub New (direction As PipeDirection, inheritability As HandleInheritability, bufferSize As Integer, pipeSecurity As PipeSecurity)

Параметры

direction
PipeDirection

Одно из значений перечисления, определяющее направление канала.

Данные в анонимных каналах могут передаваться только в одном направлении, поэтому для параметра direction нельзя задать значение InOut.

inheritability
HandleInheritability

Одно из значений перечисления, определяющее, может ли базовый дескриптор наследоваться дочерними процессами.

bufferSize
Int32

Размер буфера. Это значение должно быть больше или равно 0.

pipeSecurity
PipeSecurity

Объект, определяющий правила управления доступом и аудита безопасности для канала.

Атрибуты

Исключения

Параметру inheritability не присвоено значение None или Inheritable.

-или-

Значение параметраbufferSize меньше 0.

Параметру direction задается значение InOut.

Комментарии

Значение PipeDirectionInOut не поддерживается, так как анонимные каналы определены как односторонние.

Применяется к