public class NetworkStream : Stream
|
NetworkStream does not support random access to the network data stream. The NetworkStream.CanSeek property is always false; reading the NetworkStream.Position property or calling the NetworkStream.Seek method will throw a NotSupportedException.
ctor #1 | Overloaded:.ctor(Socket socket) Creates a new instance of the NetworkStream class for the specified Socket. |
ctor #2 | Overloaded:.ctor(Socket socket, bool ownsSocket) Initializes a new instance of the NetworkStream class for the specified socket with the specified Socket ownership. |
ctor #3 | Overloaded:.ctor(Socket socket, FileAccess access) Creates a new instance of the NetworkStream class for the specified Socket with the specified access rights. |
ctor #4 | Overloaded:.ctor(Socket socket, FileAccess access, bool ownsSocket) Creates a new instance of the NetworkStream class for the specified Socket with the specified access rights and the specified Socket ownership. |
CanRead | Read-only Overridden: Gets a value indicating whether the current stream supports reading. |
CanSeek | Read-only Overridden: Gets a value indicating whether the stream supports seeking. This property always returns false. |
CanWrite | Read-only Overridden: Gets a value that indicates whether the current stream supports writing. |
DataAvailable | Read-only Gets a value indicating whether data is available on the stream to be read. |
Length | Read-only Overridden: The length of the data available on the stream. This property always throws a NotSupportedException. |
Position | Read-write Overridden: Gets or sets the current position in the stream. This property always throws a NotSupportedException. |
BeginRead | Overridden: Begins an asynchronous read from a stream. |
BeginWrite | Overridden: Begins an asynchronous write to a stream. |
Close | Overridden: Closes the stream and optionally closes the underlying socket. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
EndRead | Overridden: Handles the end of an asynchronous read. |
EndWrite | Overridden: Handles the end of an asynchronous write. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
Flush | Overridden: Flushes data from the stream. This method is reserved for future use. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
Read | Overridden: Reads data from the stream. |
ReadByte (inherited from System.IO.Stream) |
See base class member description: System.IO.Stream.ReadByte Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. |
Seek | Overridden: Sets the current position of the stream to the given value. This method always throws a NotSupportedException. |
SetLength | Overridden: Sets the length of the stream. This method always throws a NotSupportedException. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Write | Overridden: Writes data to the stream. |
WriteByte (inherited from System.IO.Stream) |
See base class member description: System.IO.Stream.WriteByte Writes a byte to the current position in the stream and advances the position within the stream by one byte. |
Readable | Read-write Gets or sets a value indicating that the stream can be read. |
Socket | Read-only Gets the underlying network connection. |
Writeable | Read-write Gets a value that indicates whether the stream is writable. |
CreateWaitHandle (inherited from System.IO.Stream) |
See base class member description: System.IO.Stream.CreateWaitHandle Allocates a WaitHandle object. |
Dispose | Cleans up a network stream. |
Finalize | Overridden: Frees resources used by the NetworkStream. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public NetworkStream( |
socket
Exception Type | Condition |
---|---|
ArgumentNullException | socket is null. |
ArgumentException | socket is not connected -or- The Socket.SocketType property of socket is not SocketType.Stream. |
IOException | socket is a nonblocking socket. |
socket
ownsSocket
Exception Type | Condition |
---|---|
ArgumentNullException | socket is null. |
ArgumentException | socket is not connected -or- The Socket.SocketType property of socket is not SocketType.Stream. |
IOException | socket is a nonblocking socket. |
public NetworkStream( |
socket
access
Exception Type | Condition |
---|---|
ArgumentNullException | socket is null. |
ArgumentException | socket is not connected -or- The Socket.SocketType property of socket is not SocketType.Stream. |
IOException | socket is a nonblocking socket. |
public NetworkStream( |
socket
access
ownsSocket
Exception Type | Condition |
---|---|
ArgumentNullException | socket is null. |
ArgumentException | socket is not connected -or- The Socket.SocketType property of socket is not SocketType.Stream. |
IOException | socket is a nonblocking socket. |
public override bool CanRead {get;}
|
public override bool CanSeek {get;}
|
public override bool CanWrite {get;}
|
public virtual bool DataAvailable {get;}
|
public override long Length {get;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any access. |
public override long Position {get; set;}
|
Exception Type | Condition |
---|---|
NotSupportedException | Any access. |
protected bool Readable {get; set;}
|
The NetworkStream.Readable property is set when the NetworkStream is initialized.
protected Socket Socket {get;}
|
The NetworkStream.Socket property is set when the NetworkStream is initialized.
protected bool Writeable {get; set;}
|
The NetworkStream.Writeable property is set when the NetworkStream is initialized.
public override IAsyncResult BeginRead( |
buffer
offset
size
callback
state
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | buffer is smaller than the requested number of bytes. |
IOException | There is a failure while reading from the network. |
public override IAsyncResult BeginWrite( |
buffer
offset
size
callback
state
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | buffer is smaller than the requested number of bytes. |
IOException | There is a failure while writing to the network. |
public override void Close(); |
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
protected virtual WaitHandle CreateWaitHandle(); |
Use this method if you implement the asynchronous methods and require a way of blocking in Stream.EndRead or Stream.EndWrite until the asynchronous operation is complete.
protected virtual void Dispose( |
disposing
public override int EndRead( |
asyncResult
Exception Type | Condition |
---|---|
ArgumentException | asyncResult is null. |
IOException | An error occurs while reading the network. |
public override void EndWrite( |
asyncResult
Exception Type | Condition |
---|---|
ArgumentNullException | asyncResult is null. |
IOException | An error occurs while writing to the network. |
~NetworkStream(); |
public override void Flush(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
buffer
offset
size
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | buffer is smaller than the requested number of bytes. |
IOException | There is a failure while reading from the network. |
public virtual int ReadByte(); |
Exception Type | Condition |
---|---|
IOException | The stream is closed. |
NotSupportedException | The stream does not support reading. |
ObjectDisposedException | Methods were called after the stream was closed. |
Attempts to manipulate the stream after the stream has been closed could throw an ObjectDisposedException.
public override long Seek(long offset, Seek( |
offset
origin
Exception Type | Condition |
---|---|
NotSupportedException | Any access. |
public override void SetLength( |
value
Exception Type | Condition |
---|---|
NotSupportedException | Any access. |
public virtual string ToString(); |
buffer
offset
size
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is null. |
ArgumentException | buffer is smaller than the requested number of bytes. |
IOException | There is a failure while writing to the network. |
public virtual void WriteByte( |
value
Exception Type | Condition |
---|---|
IOException | The stream is closed. |
NotSupportedException | The stream does not support writing, or the stream is already closed. |
ObjectDisposedException | Methods were called after the stream was closed. |