diff --git a/nanoFramework.System.Net/Security/SslStream.cs b/nanoFramework.System.Net/Security/SslStream.cs
index 2f6705a..9f80de6 100644
--- a/nanoFramework.System.Net/Security/SslStream.cs
+++ b/nanoFramework.System.Net/Security/SslStream.cs
@@ -325,13 +325,13 @@ internal void Authenticate(bool isServer, string targetHost, X509Certificate cer
public bool IsServer { get { return _isServer; } }
///
- /// Gets the length of the stream. (Overrides NetworkStream. . :: . .Length.)
+ /// Gets the number of bytes of decrypted data available to be read from the stream.
///
public override long Length
{
get
{
- if (_disposed == true) throw new ObjectDisposedException();
+ if (_disposed) throw new ObjectDisposedException();
if (_socket == null) throw new IOException();
return SslNative.DataAvailable(_socket);
@@ -339,13 +339,13 @@ public override long Length
}
///
- /// Gets a value the indicates whether data is available in the stream. (Overrides NetworkStream. . :: . .DataAvailable.)
+ /// Gets a value that indicates whether decrypted data is available on the stream to be read.
///
public override bool DataAvailable
{
get
{
- if (_disposed == true) throw new ObjectDisposedException();
+ if (_disposed) throw new ObjectDisposedException();
if (_socket == null) throw new IOException();
return (SslNative.DataAvailable(_socket) > 0);
@@ -393,9 +393,9 @@ protected override void Dispose(bool disposing)
///
/// An array that receives the bytes read from this stream.
/// An integer that contains the zero-based location in buffer at which to begin storing the data read from this stream.
- /// The maximum number of bytes to read from this stream.
+ /// The maximum number of bytes to read from this stream.
///
- public override int Read(byte[] buffer, int offset, int size)
+ public override int Read(byte[] buffer, int offset, int count)
{
if (buffer == null)
{
@@ -412,24 +412,24 @@ public override int Read(byte[] buffer, int offset, int size)
throw new ArgumentOutOfRangeException();
}
- if (size < 0 || size > buffer.Length - offset)
+ if (count < 0 || count > buffer.Length - offset)
{
throw new ArgumentOutOfRangeException();
}
- return SslNative.SecureRead(_socket, buffer, offset, size, _socket.ReceiveTimeout);
+ return SslNative.SecureRead(_socket, buffer, offset, count, _socket.ReceiveTimeout);
}
///
/// Write the specified number of bytes to the underlying stream using the specified buffer and offset.
///
/// An array that supplies the bytes written to the stream.
- /// he zero-based location in buffer at which to begin reading bytes to be written to the stream.
- /// The number of bytes to read from buffer.
+ /// The zero-based location in buffer at which to begin reading bytes to be written to the stream.
+ /// The number of bytes to read from buffer.
/// is .
///
///
- /// or is less than zero
+ /// or is less than zero
///
///
/// -or-
@@ -441,7 +441,7 @@ public override int Read(byte[] buffer, int offset, int size)
/// -or-
///
///
- /// + is greater than the length of .
+ /// + is greater than the length of .
///
///
/// The stream has been disposed.
@@ -449,7 +449,7 @@ public override int Read(byte[] buffer, int offset, int size)
public override void Write(
byte[] buffer,
int offset,
- int size)
+ int count)
{
if (buffer == null)
{
@@ -466,14 +466,14 @@ public override void Write(
throw new ArgumentOutOfRangeException();
}
- if (size < 0 || size > buffer.Length - offset)
+ if (count < 0 || count > buffer.Length - offset)
{
throw new ArgumentOutOfRangeException();
}
- int written = SslNative.SecureWrite(_socket, buffer, offset, size, _socket.SendTimeout);
+ int written = SslNative.SecureWrite(_socket, buffer, offset, count, _socket.SendTimeout);
- if (written <= 0 && size > 0)
+ if (written <= 0 && count > 0)
{
throw new IOException();
}
diff --git a/nanoFramework.System.Net/Sockets/Socket.cs b/nanoFramework.System.Net/Sockets/Socket.cs
index d5c1fa8..d2763ae 100644
--- a/nanoFramework.System.Net/Sockets/Socket.cs
+++ b/nanoFramework.System.Net/Sockets/Socket.cs
@@ -181,7 +181,7 @@ public EndPoint RemoteEndPoint
}
///
- /// Gets a value that indicates whether a is connected to a remote host as of the last or operation.
+ /// Gets a value that indicates whether a is connected to a remote host as of the last or operation.
///
///
/// if the was connected to a remote resource as of the most recent operation; otherwise, .
@@ -766,30 +766,12 @@ public int ReceiveFrom(byte[] buffer, int offset, int size, SocketFlags socketFl
if (_rightEndPoint == null)
{
- // socket must have connection established or previously accepted a connection
+ // socket must be bound (by Bind, Connect or SendTo)
throw new SocketException(SocketError.NotConnected);
}
- EndPoint endPointSnapshot = remoteEP;
- Snapshot(ref endPointSnapshot);
-
- int bytesTransferred = 0;
-
- bytesTransferred = NativeSocket.recvfrom(this, buffer, offset, size, (int)socketFlags, m_recvTimeout, ref remoteEP);
-
- if (!remoteEP.Equals(endPointSnapshot))
- {
- // no need to create a new EndPoint here if it's different from the orignal
- // because the interpreter has already created a new instance of an IPEndPoint
-
- if (_rightEndPoint == null)
- {
- // save a copy of the EndPoint
- _rightEndPoint = remoteEP;
- }
- }
-
- return bytesTransferred;
+ // recvfrom always replaces remoteEP with a new IPEndPoint holding the sender's address; the caller's instance is never modified
+ return NativeSocket.recvfrom(this, buffer, offset, size, (int)socketFlags, m_recvTimeout, ref remoteEP);
}
///
@@ -1091,6 +1073,9 @@ void IDisposable.Dispose()
GC.SuppressFinalize(this);
}
+ ///
+ /// Releases unmanaged resources used by the before it is reclaimed by garbage collection.
+ ///
~Socket()
{
Dispose(false);