AnonymousPipeServerStream Konstruktor
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menginisialisasi instans baru kelas AnonymousPipeServerStream.
Overload
AnonymousPipeServerStream()
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
Menginisialisasi instans baru kelas AnonymousPipeServerStream.
public:
AnonymousPipeServerStream();
public AnonymousPipeServerStream ();
Public Sub New ()
Keterangan
Untuk AnonymousPipeServerStream konstruktor tanpa PipeDirection parameter, arah defaultnya adalah Out. Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.
Konstruktor ini membuat AnonymousPipeServerStream objek yang memiliki ukuran buffer default, tidak ada keamanan pipa, dan HandleInheritability nilai None.
Berlaku untuk
AnonymousPipeServerStream(PipeDirection)
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
Menginisialisasi instans AnonymousPipeServerStream baru kelas dengan arah pipa yang ditentukan.
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)
Parameter
- direction
- PipeDirection
Salah satu nilai enumerasi yang menentukan arah pipa.
Pipa anonim hanya dapat berada dalam satu arah, sehingga direction
tidak dapat diatur ke InOut.
Pengecualian
direction
diatur ke InOut.
Keterangan
Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.
Konstruktor ini membuat AnonymousPipeServerStream objek yang memiliki ukuran buffer default, tidak ada keamanan pipa, dan HandleInheritability nilai None.
Berlaku untuk
AnonymousPipeServerStream(PipeDirection, HandleInheritability)
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
Menginisialisasi instans AnonymousPipeServerStream baru kelas dengan arah pipa dan mode warisan yang ditentukan.
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)
Parameter
- direction
- PipeDirection
Salah satu nilai enumerasi yang menentukan arah pipa.
Pipa anonim hanya dapat berada dalam satu arah, sehingga direction
tidak dapat diatur ke InOut.
- inheritability
- HandleInheritability
Salah satu nilai enumerasi yang menentukan apakah handel yang mendasar dapat diwariskan oleh proses anak. Harus diatur ke atau NoneInheritable.
Pengecualian
inheritability
tidak diatur ke atau NoneInheritable.
direction
diatur ke InOut.
Contoh
Contoh berikut menunjukkan metode untuk mengirim string dari proses induk ke proses anak menggunakan pipa anonim. Dalam contoh ini, AnonymousPipeServerStream objek dibuat dalam proses induk dengan PipeDirection nilai Out.
//<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>
Keterangan
Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.
Konstruktor ini membuat AnonymousPipeServerStream objek yang memiliki ukuran buffer default dan tidak ada keamanan pipa.
Berlaku untuk
AnonymousPipeServerStream(PipeDirection, SafePipeHandle, SafePipeHandle)
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
Menginisialisasi instans AnonymousPipeServerStream baru kelas dari handel pipa yang ditentukan.
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)
Parameter
- direction
- PipeDirection
Salah satu nilai enumerasi yang menentukan arah pipa.
Pipa anonim hanya dapat berada dalam satu arah, sehingga direction
tidak dapat diatur ke InOut.
- serverSafePipeHandle
- SafePipeHandle
Handel aman untuk pipa yang akan dienkapsulasi objek ini AnonymousPipeServerStream .
- clientSafePipeHandle
- SafePipeHandle
Handel yang aman untuk AnonymousPipeClientStream objek.
- Atribut
Pengecualian
serverSafePipeHandle
atau clientSafePipeHandle
merupakan handel yang tidak valid.
serverSafePipeHandle
atau clientSafePipeHandle
adalah null
.
direction
diatur ke InOut.
Keterangan
Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.
Berlaku untuk
AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32)
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
- Sumber:
- AnonymousPipeServerStream.cs
Menginisialisasi instans AnonymousPipeServerStream baru kelas dengan arah pipa yang ditentukan, mode pewarisan, dan ukuran buffer.
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)
Parameter
- direction
- PipeDirection
Salah satu nilai enumerasi yang menentukan arah pipa.
Pipa anonim hanya dapat berada dalam satu arah, sehingga direction
tidak dapat diatur ke InOut.
- inheritability
- HandleInheritability
Salah satu nilai enumerasi yang menentukan apakah handel yang mendasar dapat diwariskan oleh proses anak. Harus diatur ke atau NoneInheritable.
- bufferSize
- Int32
Ukuran buffer. Nilai ini harus lebih besar dari atau sama dengan 0.
- Atribut
Pengecualian
direction
diatur ke InOut.
Keterangan
Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.
Konstruktor ini membuat AnonymousPipeServerStream objek tanpa keamanan pipa.
Berlaku untuk
AnonymousPipeServerStream(PipeDirection, HandleInheritability, Int32, PipeSecurity)
Menginisialisasi instans AnonymousPipeServerStream baru kelas dengan arah pipa yang ditentukan, mode warisan, ukuran buffer, dan keamanan pipa.
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)
Parameter
- direction
- PipeDirection
Salah satu nilai enumerasi yang menentukan arah pipa.
Pipa anonim hanya dapat berada dalam satu arah, sehingga direction
tidak dapat diatur ke InOut.
- inheritability
- HandleInheritability
Salah satu nilai enumerasi yang menentukan apakah handel yang mendasar dapat diwariskan oleh proses anak.
- bufferSize
- Int32
Ukuran buffer. Nilai ini harus lebih besar dari atau sama dengan 0.
- pipeSecurity
- PipeSecurity
Objek yang menentukan kontrol akses dan keamanan audit untuk pipa.
- Atribut
Pengecualian
direction
diatur ke InOut.
Keterangan
Nilai PipeDirectionInOut tidak didukung karena pipa anonim didefinisikan sebagai satu arah.