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 0c22f64
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: nanoFramework.System.Net/Security/SslStream.cs
+2-5Lines changed: 2 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -47,18 +47,15 @@ public class SslStream : NetworkStream
47
47
/// Initializes a new instance of the SslStream class using the specified Socket.
48
48
/// </summary>
49
49
/// <param name="socket">A valid socket that currently has a TCP connection.</param>
50
+
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is <see langword="null"/>.</exception>
51
+
/// <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"/>.</exception>
50
52
/// <remarks>
51
53
/// The SslStream maintains the lifetime of the socket. When the SslStream object is disposed,
Copy file name to clipboardExpand all lines: nanoFramework.System.Net/Sockets/NetworkStream.cs
+30-41Lines changed: 30 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ public class NetworkStream : Stream
23
23
protectedint_socketType;
24
24
25
25
/// <summary>
26
-
/// Internal endpoint ref used for dgram sockets
26
+
/// Internal endpoint ref of the remote peer
27
27
/// </summary>
28
28
protectedEndPoint_remoteEndPoint;
29
29
@@ -40,7 +40,7 @@ public class NetworkStream : Stream
40
40
/// </summary>
41
41
/// <param name="socket">The <see cref="Socket"/> that the <see cref="NetworkStream"/> will use to send and receive data.</param>
42
42
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is <see langword="null"/>.</exception>
43
-
/// <exception cref="IOException">The <paramref name="socket"/> is not connected or the remote endpoint is not available.</exception>
43
+
/// <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"/>.</exception>
44
44
publicNetworkStream(Socketsocket)
45
45
:this(socket,false)
46
46
{
@@ -55,7 +55,7 @@ public NetworkStream(Socket socket)
55
55
/// <param name="ownsSocket"><see langword="true"/> to indicate that the <see cref="NetworkStream"/> will take ownership of the <see cref="Socket"/>;
56
56
/// otherwise, <see langword="false"/>.</param>
57
57
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is <see langword="null"/>.</exception>
58
-
/// <exception cref="IOException">The <paramref name="socket"/> is not connected or the remote endpoint is not available.</exception>
58
+
/// <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"/>.</exception>
59
59
publicNetworkStream(Socketsocket,boolownsSocket)
60
60
{
61
61
ArgumentNullException.ThrowIfNull(socket);
@@ -72,6 +72,11 @@ public NetworkStream(Socket socket, bool ownsSocket)
72
72
thrownewIOException(errCode.ToString(),e);
73
73
}
74
74
75
+
if(socket.SocketType!=SocketType.Stream)
76
+
{
77
+
thrownewIOException();
78
+
}
79
+
75
80
// Set the internal socket
76
81
_socket=socket;
77
82
@@ -84,7 +89,11 @@ public NetworkStream(Socket socket, bool ownsSocket)
84
89
/// <summary>
85
90
/// Gets a value that indicates whether the <see cref="NetworkStream"/> supports reading.
86
91
/// </summary>
87
-
/// <value><see langword="true"/> if data can be read from the stream; otherwise, <see langword="false"/>.</value>
92
+
/// <value>true if data can be read from the stream; otherwise, false. The default value is true.</value>
93
+
/// <remarks>
94
+
/// If CanRead is true, <see cref="NetworkStream"/> allows calls to the <see cref="Read(byte[], int, int)"/> method. Provide the appropriate FileAccess enumerated value in the constructor to set
95
+
/// the readability and write-ability of the <see cref="NetworkStream"/>. The CanRead property is set when the <see cref="NetworkStream"/> is initialized.
96
+
/// </remarks>
88
97
publicoverrideboolCanRead{get{returntrue;}}
89
98
90
99
/// <summary>
@@ -215,7 +224,7 @@ public virtual bool DataAvailable
215
224
/// <summary>
216
225
/// Closes the <see cref="NetworkStream"/> after waiting the specified time to allow data to be sent.
217
226
/// </summary>
218
-
/// <param name="timeout">A32-bit signed integer that specifies the number of milliseconds to wait to send any remaining data before closing.</param>
227
+
/// <param name="timeout">A 32-bit signed integer that specifies the number of milliseconds to wait to send any remaining data before closing.</param>
219
228
/// <exception cref="ArgumentOutOfRangeException"><paramref name="timeout"/> is less than -1.</exception>
220
229
/// <remarks>
221
230
/// <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 <see cref="Socket"/>, it is closed as well.</para>
@@ -272,16 +281,18 @@ public override void Flush()
272
281
/// Reads data from the <see cref="NetworkStream"/>.
273
282
/// </summary>
274
283
/// <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>
275
-
/// <param name="offset">The location in <paramref name="buffer"/> to begin storing the data.</param>
284
+
/// <param name="offset">The location in <paramref name="buffer"/> to begin storing the data to.</param>
276
285
/// <param name="count">The number of bytes to read from the <see cref="NetworkStream"/>.</param>
277
-
/// <returns>The number of bytes read from the <see cref="NetworkStream"/>.</returns>
286
+
/// <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>
287
+
/// <exception cref="IOException">The underlying <see cref="Socket"/> is closed. -or- There was a failure while reading from the network.</exception>
278
288
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
279
-
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is less than0 or greater than the length of <paramref name="buffer"/>; or <paramref name="count"/> is less than0 or greater than the length of <paramref name="buffer"/> minus <paramref name="offset"/>.</exception>
280
289
/// <exception cref="ObjectDisposedException">The <see cref="NetworkStream"/> is closed.</exception>
281
-
/// <exception cref="IOException">The underlying <see cref="Socket"/>is closed, or an error occurred when accessing the socket.</exception>
290
+
/// <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>
282
291
/// <remarks>
283
-
/// <para>This method reads data into the <paramref name="buffer"/> parameter and returns the number of bytes successfully read. If no data is available for reading, the <see cref="Read(byte[], int, int)"/> method returns0. The read operation reads as much data as is available, up to the number of bytes specified by the <paramref name="count"/> parameter.</para>
284
-
/// <para>If the remote host shuts down the connection, and all available data has been received, the <see cref="Read(byte[], int, int)"/> method completes immediately and returns zero bytes.</para>
292
+
/// <para>This method reads data into the <paramref name="buffer"/> parameter and returns the number of bytes successfully read. The <see cref="Read(byte[], int, int)"/> 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>
293
+
/// <note type="important">
294
+
/// 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"/>.
@@ -403,19 +403,21 @@ public override void SetLength(long value)
403
403
thrownewNotSupportedException();
404
404
}
405
405
406
-
/// <summary>
406
+
/// <summary>
407
407
/// Writes data to the <see cref="NetworkStream"/>.
408
408
/// </summary>
409
409
/// <param name="buffer">An array of type <see cref="byte"/> that contains the data to write to the <see cref="NetworkStream"/>.</param>
410
410
/// <param name="offset">The location in <paramref name="buffer"/> from which to start writing data.</param>
411
411
/// <param name="count">The number of bytes to write to the <see cref="NetworkStream"/>.</param>
412
-
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
413
-
/// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is less than0 or greater than the length of <paramref name="buffer"/>; or <paramref name="count"/> is less than0 or greater than the length of <paramref name="buffer"/> minus <paramref name="offset"/>.</exception>
412
+
/// <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>
414
413
/// <exception cref="ObjectDisposedException">The <see cref="NetworkStream"/> is closed.</exception>
415
-
/// <exception cref="IOException">There was a failure while writing to the network, or the underlying <see cref="Socket"/> is closed.</exception>
414
+
/// <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>
415
+
/// <exception cref="ArgumentNullException"><paramref name="buffer"/> is <see langword="null"/>.</exception>
416
416
/// <remarks>
417
417
/// The <see cref="Write(byte[], int, int)"/> method starts at the specified <paramref name="offset"/> and sends <paramref name="count"/> bytes from the contents of <paramref name="buffer"/> to the network.
418
418
/// The <see cref="Write(byte[], int, int)"/> method blocks until the requested number of bytes is sent or a <see cref="SocketException"/> is thrown.
419
+
/// If you receive a <see cref="SocketException"/>, use the <see cref="SocketException.ErrorCode"/> property to obtain
420
+
/// 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