You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bb4b9c6
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -34,57 +34,17 @@ public class NetworkStream : Stream
34
34
/// </summary>
35
35
protectedbool_disposed;
36
36
37
-
// Summary:
38
-
// Creates a new instance of the System.Net.Sockets.NetworkStream class for
39
-
// the specified System.Net.Sockets.Socket.
40
-
//
41
-
// Parameters:
42
-
// socket:
43
-
// The System.Net.Sockets.Socket that the System.Net.Sockets.NetworkStream will
44
-
// use to send and receive data.
45
-
//
46
-
// Exceptions:
47
-
// System.ArgumentNullException:
48
-
// socket is null.
49
-
//
50
-
// System.IO.IOException:
51
-
// socket is not connected.-or- The System.Net.Sockets.Socket.SocketType property
52
-
// of socket is not System.Net.Sockets.SocketType.Stream.-or- socket is in a
53
-
// nonblocking state.
54
-
55
37
/// <summary>
56
38
/// Creates a new instance of the <see cref="NetworkStream"/> class for the specified <see cref="Socket"/>.
57
39
/// </summary>
58
40
/// <param name="socket">The <see cref="Socket"/> that the <see cref="NetworkStream"/> will use to send and receive data.</param>
41
+
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is <see langword="null"/>.</exception>
42
+
/// <exception cref="IOException"><paramref name="socket"/> is not connected. -or- The <see cref="Socket.SocketType"/> property of <paramref name="socket"/> is not <see cref="SocketType.Stream"/>. -or- <paramref name="socket"/> is in a nonblocking state.</exception>
59
43
publicNetworkStream(Socketsocket)
60
44
:this(socket,false)
61
45
{
62
46
}
63
47
64
-
//
65
-
// Summary:
66
-
// Initializes a new instance of the System.Net.Sockets.NetworkStream class
67
-
// for the specified System.Net.Sockets.Socket with the specified System.Net.Sockets.Socket
68
-
// ownership.
69
-
//
70
-
// Parameters:
71
-
// ownsSocket:
72
-
// true to indicate that the System.Net.Sockets.NetworkStream will take ownership
73
-
// of the System.Net.Sockets.Socket; otherwise, false.
74
-
//
75
-
// socket:
76
-
// The System.Net.Sockets.Socket that the System.Net.Sockets.NetworkStream will
77
-
// use to send and receive data.
78
-
//
79
-
// Exceptions:
80
-
// System.IO.IOException:
81
-
// socket is not connected.-or- The value of the System.Net.Sockets.Socket.SocketType
82
-
// property of socket is not System.Net.Sockets.SocketType.Stream.-or- socket
83
-
// is in a nonblocking state.
84
-
//
85
-
// System.ArgumentNullException:
86
-
// socket is null.
87
-
88
48
/// <summary>
89
49
/// Initializes a new instance of the <see cref="NetworkStream"/> class for the specified
90
50
/// <see cref="Socket"/> with the specified <see cref="Socket"/> ownership.
@@ -93,6 +53,8 @@ public NetworkStream(Socket socket)
93
53
/// use to send and receive data.</param>
94
54
/// <param name="ownsSocket"><see langword="true"/> to indicate that the <see cref="NetworkStream"/> will take ownership of the <see cref="Socket"/>;
95
55
/// otherwise, <see langword="false"/>.</param>
56
+
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is <see langword="null"/>.</exception>
57
+
/// <exception cref="IOException"><paramref name="socket"/> is not connected. -or- The <see cref="Socket.SocketType"/> property of <paramref name="socket"/> is not <see cref="SocketType.Stream"/>. -or- <paramref name="socket"/> is in a nonblocking state.</exception>
96
58
publicNetworkStream(Socketsocket,boolownsSocket)
97
59
{
98
60
if(socket==null)thrownewArgumentNullException();
@@ -224,24 +186,11 @@ public virtual bool DataAvailable
224
186
}
225
187
}
226
188
227
-
//
228
-
// Summary:
229
-
// Closes the System.Net.Sockets.NetworkStream after waiting the specified time
230
-
// to allow data to be sent.
231
-
//
232
-
// Parameters:
233
-
// timeout:
234
-
// A 32-bit signed integer that specifies how long to wait to send any remaining
235
-
// data before closing.
236
-
//
237
-
// Exceptions:
238
-
// System.ArgumentOutOfRangeException:
239
-
// timeout is less than -1.
240
-
241
189
/// <summary>
242
190
/// Closes the <see cref="NetworkStream"/> after waiting the specified time to allow data to be sent.
243
191
/// </summary>
244
192
/// <param name="timeout">A 32-bit signed integer that specifies the number of milliseconds to wait to send any remaining data before closing.</param>
193
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="timeout"/> is less than -1.</exception>
245
194
/// <remarks>
246
195
/// <para>The <see cref="Close"/> method frees both unmanaged and managed resources associated with the <see cref="NetworkStream"/>. If the <see cref="NetworkStream"/> owns the underlying Socket, it is closed as well.</para>
247
196
/// </remarks>
@@ -250,7 +199,7 @@ public void Close(int timeout)
250
199
if(timeout<-1)
251
200
thrownewArgumentOutOfRangeException();
252
201
253
-
System.Threading.Thread.Sleep(timeout);
202
+
Threading.Thread.Sleep(timeout);
254
203
255
204
Close();
256
205
}
@@ -289,34 +238,21 @@ public override void Flush()
289
238
{
290
239
}
291
240
292
-
// Exceptions:
293
-
// System.IO.IOException:
294
-
// The underlying System.Net.Sockets.Socket is closed.
295
-
//
296
-
// System.ArgumentNullException:
297
-
// buffer is null.
298
-
//
299
-
// System.ObjectDisposedException:
300
-
// The System.Net.Sockets.NetworkStream is closed.-or- There is a failure reading
301
-
// from the network.
302
-
//
303
-
// System.ArgumentOutOfRangeException:
304
-
// offset is less than 0.-or- offset is greater than the length of buffer.-or-
305
-
// size is less than 0.-or- size is greater than the length of buffer minus
306
-
// the value of the offset parameter. -or-An error occurred when accessing the
307
-
// socket. See the Remarks section for more information.
308
-
309
241
/// <summary>
310
242
/// Reads data from the NetworkStream.
311
243
/// </summary>
312
-
/// <param name="buffer">An array of type Byte that is the location in memory to store data read from the NetworkStream.</param>
313
-
/// <param name="offset">The location in buffer to begin storing the data to.</param>
314
-
/// <param name="count">The number of bytes to read from the NetworkStream.</param>
315
-
/// <returns>The number of bytes read from the NetworkStream.</returns>
244
+
/// <param name="buffer">An array of type <see cref="byte"/> that is the location in memory to store data read from the <see cref="NetworkStream"/>.</param>
245
+
/// <param name="offset">The location in <paramref name="buffer"/> to begin storing the data to.</param>
246
+
/// <param name="count">The number of bytes to read from the <see cref="NetworkStream"/>.</param>
247
+
/// <returns>The total number of bytes read into the buffer between zero (0) and the requested count. The method returns zero (0) only if zero bytes were requested or if no more bytes are available because the peer socket performed a graceful shutdown.</returns>
248
+
/// <exception cref="IOException">The underlying <see cref="Socket"/> is closed.</exception>
249
+
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
250
+
/// <exception cref="ObjectDisposedException">The <see cref="NetworkStream"/> is closed or there is a failure reading from the network.</exception>"
251
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is less than 0 or greater than the length of <paramref name="buffer"/>. -or- <paramref name="count"/> is less than 0 or greater than the length of <paramref name="buffer"/> minus the value of the <paramref name="offset"/> parameter.</exception>
316
252
/// <remarks>
317
-
/// <para>This method reads data into the buffer parameter and returns the number of bytes successfully read. If no data is available for reading, the Read method returns 0. The Read operation reads as much data as is available, up to the number of bytes specified by the count parameter. If the remote host shuts down the connection, and all available data has been received, the Read method completes immediately and return zero bytes.</para>
253
+
/// <para>This method reads data into the <paramref name="buffer"/> parameter and returns the number of bytes successfully read. The <see cref="Read"/> operation reads as much data as is available, up to the number of bytes specified by the <paramref name="count"/> parameter. If the remote host shuts down the connection, and all available data has been received, the Read method completes immediately and return zero bytes.</para>
318
254
/// <note type="important">
319
-
/// Check to see if the <see cref="NetworkStream"/> is readable by calling the <see cref="CanRead"/> property. If you attempt to read from a <see cref="NetworkStream"/> that is not readable, you will get an IOException.
255
+
/// Check to see if the <see cref="NetworkStream"/> is readable by calling the <see cref="CanRead"/> property. If you attempt to read from a <see cref="NetworkStream"/> that is not readable, you will get an <see cref="IOException"/> .
@@ -372,46 +308,20 @@ public override void SetLength(long value)
372
308
thrownewNotSupportedException();
373
309
}
374
310
375
-
//
376
-
// Summary:
377
-
// Writes data to the System.Net.Sockets.NetworkStream.
378
-
//
379
-
// Parameters:
380
-
// offset:
381
-
// The location in buffer from which to start writing data.
382
-
//
383
-
// size:
384
-
// The number of bytes to write to the System.Net.Sockets.NetworkStream.
385
-
//
386
-
// buffer:
387
-
// An array of type System.Byte that contains the data to write to the System.Net.Sockets.NetworkStream.
388
-
//
389
-
// Exceptions:
390
-
// System.ArgumentOutOfRangeException:
391
-
// offset is less than 0.-or- offset is greater than the length of buffer.-or-
392
-
// size is less than 0.-or- size is greater than the length of buffer minus
393
-
// the value of the offset parameter.
394
-
//
395
-
// System.ObjectDisposedException:
396
-
// The System.Net.Sockets.NetworkStream is closed.-or- There was a failure reading
397
-
// from the network.
398
-
//
399
-
// System.IO.IOException:
400
-
// There was a failure while writing to the network. -or-An error occurred when
401
-
// accessing the socket. See the Remarks section for more information.
402
-
//
403
-
// System.ArgumentNullException:
404
-
// buffer is null.
405
-
406
311
/// <summary>
407
312
/// Writes data to the <see cref="NetworkStream"/>.
408
313
/// </summary>
409
-
/// <param name="buffer">An array of type Byte that contains the data to write to the NetworkStream.</param>
410
-
/// <param name="offset">The location in buffer from which to start writing data.</param>
411
-
/// <param name="count">The number of bytes to write to the NetworkStream.</param>
314
+
/// <param name="buffer">An array of type <see cref="byte"/> that contains the data to write to the <see cref="NetworkStream"/>.</param>
315
+
/// <param name="offset">The location in <paramref name="buffer"/> from which to start writing data.</param>
316
+
/// <param name="count">The number of bytes to write to the <see cref="NetworkStream"/>.</param>
317
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is less than 0 or greater than the length of <paramref name="buffer"/>. -or- <paramref name="count"/> is less than 0 or greater than the length of <paramref name="buffer"/> minus the value of the <paramref name="offset"/> parameter.</exception>
318
+
/// <exception cref="ObjectDisposedException">The <see cref="NetworkStream"/> is closed or there is a failure reading from the network.</exception>
319
+
/// <exception cref="IOException">There was a failure while writing to the network. -or-An error occurred when accessing the socket. See the Remarks section for more information.</exception>
320
+
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
321
+
/// <exception cref="NotSupportedException">The underlying <see cref="Socket"/> is not of type <see cref="SocketType.Stream"/> or <see cref="SocketType.Dgram"/>.</exception>
412
322
/// <remarks>
413
323
/// The Write method starts at the specified offset and sends count bytes from the contents of buffer to the network.
414
-
/// The Write method blocks until the requested number of bytes is sent or a SocketException is thrown.
324
+
/// The Write method blocks until the requested number of bytes is sent or a <see cref="SocketException"/> is thrown.
415
325
/// If you receive a <see cref="SocketException"/>, use the <see cref="SocketException.ErrorCode"/> property to obtain
416
326
/// the specific error code, and refer to the Windows Sockets version 2 API error code documentation in MSDN for a detailed description of the error.
0 commit comments