PipeStream PipeStream PipeStream PipeStream Class

定义

公开管道周围的 Stream 对象,该对象同时支持匿名管道和命名管道。Exposes a Stream object around a pipe, which supports both anonymous and named pipes.

public ref class PipeStream abstract : System::IO::Stream
public abstract class PipeStream : System.IO.Stream
type PipeStream = class
    inherit Stream
Public MustInherit Class PipeStream
Inherits Stream
继承
派生

注解

PipeStream类的.NET Framework 中的命名和匿名管道操作提供的基类。The PipeStream class provides the base class for named and anonymous pipes operations in the .NET Framework. 使用NamedPipeServerStreamNamedPipeClientStream命名的管道操作的类。Use the NamedPipeServerStream and NamedPipeClientStream classes for named pipe operations. 使用AnonymousPipeServerStreamAnonymousPipeClientStream匿名管道操作的类。Use the AnonymousPipeServerStream and AnonymousPipeClientStream classes for anonymous pipe operations.

有关管道的详细信息,请参阅管道For more information about pipes, see Pipes. 匿名管道的示例,请参阅如何:使用匿名管道进行本地进程间通信For an example of anonymous pipes, see How to: Use Anonymous Pipes for Local Interprocess Communication. 命名管道的示例,请参阅如何:使用命名管道进行网络进程间通信For an example of named pipes, see How to: Use Named Pipes for Network Interprocess Communication.

构造函数

PipeStream(PipeDirection, Int32) PipeStream(PipeDirection, Int32) PipeStream(PipeDirection, Int32) PipeStream(PipeDirection, Int32)

使用指定的 PipeDirection 值和缓冲区大小初始化 PipeStream 类的一个新实例。Initializes a new instance of the PipeStream class using the specified PipeDirection value and buffer size.

PipeStream(PipeDirection, PipeTransmissionMode, Int32) PipeStream(PipeDirection, PipeTransmissionMode, Int32) PipeStream(PipeDirection, PipeTransmissionMode, Int32) PipeStream(PipeDirection, PipeTransmissionMode, Int32)

使用指定的 PipeDirectionPipeTransmissionMode 和缓冲区大小初始化 PipeStream 类的一个新实例。Initializes a new instance of the PipeStream class using the specified PipeDirection, PipeTransmissionMode, and buffer size.

属性

CanRead CanRead CanRead CanRead

获取一个值,该值指示当前流是否支持读操作。Gets a value indicating whether the current stream supports read operations.

CanSeek CanSeek CanSeek CanSeek

获取一个值,该值指示当前流是否支持查找操作。Gets a value indicating whether the current stream supports seek operations.

CanTimeout CanTimeout CanTimeout CanTimeout

获取一个值,该值确定当前流是否可以超时。Gets a value that determines whether the current stream can time out.

(Inherited from Stream)
CanWrite CanWrite CanWrite CanWrite

获取一个值,该值指示当前流是否支持写操作。Gets a value indicating whether the current stream supports write operations.

InBufferSize InBufferSize InBufferSize InBufferSize

获取管道的入站缓冲区的大小(以字节为单位)。Gets the size, in bytes, of the inbound buffer for a pipe.

IsAsync IsAsync IsAsync IsAsync

获取一个值,该值指示 PipeStream 对象是异步打开还是同步打开。Gets a value indicating whether a PipeStream object was opened asynchronously or synchronously.

IsConnected IsConnected IsConnected IsConnected

获取或设置一个值,该值指示是否已连接 PipeStream 对象。Gets or sets a value indicating whether a PipeStream object is connected.

IsHandleExposed IsHandleExposed IsHandleExposed IsHandleExposed

获取一个值,该值指示是否公开了 PipeStream 对象的句柄。Gets a value indicating whether a handle to a PipeStream object is exposed.

IsMessageComplete IsMessageComplete IsMessageComplete IsMessageComplete

获取一个值,该值指示最近的读操作返回的消息中是否有更多数据。Gets a value indicating whether there is more data in the message returned from the most recent read operation.

Length Length Length Length

获取流长度(以字节为单位)。Gets the length of a stream, in bytes.

OutBufferSize OutBufferSize OutBufferSize OutBufferSize

获取管道的出站缓冲区的大小(以字节为单位)。Gets the size, in bytes, of the outbound buffer for a pipe.

Position Position Position Position

获取或设置当前流的当前位置。Gets or sets the current position of the current stream.

ReadMode ReadMode ReadMode ReadMode

获取或设置 PipeStream 对象的读取模式。Gets or sets the reading mode for a PipeStream object.

ReadTimeout ReadTimeout ReadTimeout ReadTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试读取多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

(Inherited from Stream)
SafePipeHandle SafePipeHandle SafePipeHandle SafePipeHandle

获取当前 PipeStream 对象所封装的本地管道末端的安全句柄。Gets the safe handle for the local end of the pipe that the current PipeStream object encapsulates.

TransmissionMode TransmissionMode TransmissionMode TransmissionMode

获取当前管道支持的管道传输模式。Gets the pipe transmission mode supported by the current pipe.

WriteTimeout WriteTimeout WriteTimeout WriteTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试写入多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

(Inherited from Stream)

方法

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

开始异步读操作。Begins an asynchronous read operation.

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

开始异步写操作。Begins an asynchronous write operation.

CheckPipePropertyOperations() CheckPipePropertyOperations() CheckPipePropertyOperations() CheckPipePropertyOperations()

验证管道是否处于可供获取或设置属性的正确状态。Verifies that the pipe is in a proper state for getting or setting properties.

CheckReadOperations() CheckReadOperations() CheckReadOperations() CheckReadOperations()

验证管道是否处于可供进行读操作的连接状态。Verifies that the pipe is in a connected state for read operations.

CheckWriteOperations() CheckWriteOperations() CheckWriteOperations() CheckWriteOperations()

验证管道是否处于可供进行写操作的连接状态。Verifies that the pipe is in a connected state for write operations.

Close() Close() Close() Close()

关闭当前流并释放与之关联的所有资源(如套接字和文件句柄)。Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. 不直接调用此方法,而应确保流得以正确释放。Instead of calling this method, ensure that the stream is properly disposed.

(Inherited from Stream)
CopyTo(Stream) CopyTo(Stream) CopyTo(Stream) CopyTo(Stream)

从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream.

(Inherited from Stream)
CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32)

使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(Inherited from Stream)
CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream)

从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream.

(Inherited from Stream)
CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken)

通过指定的取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.

(Inherited from Stream)
CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32)

使用指定的缓冲区大小,从当前流中异步读取字节并将其写入到另一流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(Inherited from Stream)
CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken)

使用指定的缓冲区大小和取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

(Inherited from Stream)
CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
CreateWaitHandle() CreateWaitHandle() CreateWaitHandle() CreateWaitHandle()

分配 WaitHandle 对象。Allocates a WaitHandle object.

(Inherited from Stream)
Dispose() Dispose() Dispose() Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

(Inherited from Stream)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放 PipeStream 类使用的非托管资源,并可以选择释放托管资源。Releases the unmanaged resources used by the PipeStream class and optionally releases the managed resources.

DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()

异步释放 Stream 使用的非托管资源。Asynchronously releases the unmanaged resources used by the Stream.

(Inherited from Stream)
EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult)

结束挂起的异步读取请求。Ends a pending asynchronous read request.

EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult)

结束挂起的异步写入请求。Ends a pending asynchronous write request.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

清除当前流的缓冲区,并使所有缓冲的数据都写入到基础设备。Clears the buffer for the current stream and causes any buffered data to be written to the underlying device.

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

异步清除此流的所有缓冲区并导致所有缓冲数据都写入基础设备中。Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

(Inherited from Stream)
FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken)

异步清理这个流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

(Inherited from Stream)
GetAccessControl() GetAccessControl() GetAccessControl() GetAccessControl()

获取一个 PipeSecurity 对象,该对象封装当前 PipeStream 对象所描述管道的访问控制列表 (ACL) 项。Gets a PipeSecurity object that encapsulates the access control list (ACL) entries for the pipe described by the current PipeStream object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeHandle(SafePipeHandle, Boolean, Boolean) InitializeHandle(SafePipeHandle, Boolean, Boolean) InitializeHandle(SafePipeHandle, Boolean, Boolean) InitializeHandle(SafePipeHandle, Boolean, Boolean)

从指定的 SafePipeHandle 对象中初始化 PipeStream 对象。Initializes a PipeStream object from the specified SafePipeHandle object.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ObjectInvariant() ObjectInvariant() ObjectInvariant() ObjectInvariant()

提供对 Contract 的支持。Provides support for a Contract.

(Inherited from Stream)
Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32)

从流中读取字节块,并将数据写入指定的缓冲区。Reads a block of bytes from a stream and writes the data to a specified buffer.

Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>)
ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32)

从当前流异步读取字节序列,并将流中的位置提升读取的字节数。Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

(Inherited from Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken)
ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken)
ReadByte() ReadByte() ReadByte() ReadByte()

从管道读取字节。Reads a byte from a pipe.

Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin)

将当前流的当前位置设置为指定值。Sets the current position of the current stream to the specified value.

SetAccessControl(PipeSecurity) SetAccessControl(PipeSecurity) SetAccessControl(PipeSecurity) SetAccessControl(PipeSecurity)

PipeSecurity 对象所指定的访问控制列表 (ACL) 项应用于由当前 PipeStream 对象指定的管道。Applies the access control list (ACL) entries specified by a PipeSecurity object to the pipe specified by the current PipeStream object.

SetLength(Int64) SetLength(Int64) SetLength(Int64) SetLength(Int64)

将当前流的长度设为指定值。Sets the length of the current stream to the specified value.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
WaitForPipeDrain() WaitForPipeDrain() WaitForPipeDrain() WaitForPipeDrain()

等待管道另一端读取所有发送的字节。Waits for the other end of the pipe to read all sent bytes.

Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32)

使用缓冲区中的数据将字节块写入当前流。Writes a block of bytes to the current stream using data from a buffer.

Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>)
WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32)

将字节序列异步写入当前流,并将流的当前位置提升写入的字节数。Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

(Inherited from Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)
WriteByte(Byte) WriteByte(Byte) WriteByte(Byte) WriteByte(Byte)

将字节写入当前流。Writes a byte to the current stream.

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

(Inherited from Stream)

扩展方法

GetAccessControl(PipeStream) GetAccessControl(PipeStream) GetAccessControl(PipeStream) GetAccessControl(PipeStream)
SetAccessControl(PipeStream, PipeSecurity) SetAccessControl(PipeStream, PipeSecurity) SetAccessControl(PipeStream, PipeSecurity) SetAccessControl(PipeStream, PipeSecurity)

安全性

InheritanceDemand
继承者完全信任。for full trust for inheritors. 不能由部分受信任代码继承此类。This class cannot be inherited by partially trusted code.

适用于