Skip to content

Commit

Permalink
Added Read(Socket socket, int size, TimeSpan timeout) method.
Browse files Browse the repository at this point in the history
  • Loading branch information
drieseng committed Jul 29, 2018
1 parent 4f5aaec commit 7b43bdc
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/Renci.SshNet/Abstractions/SocketAbstraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,30 @@ public static void SendByte(Socket socket, byte value)
}

/// <summary>
/// Receives data from a bound <see cref="Socket"/>into a receive buffer.
/// Receives data from a bound <see cref="Socket"/>.
/// </summary>
/// <param name="socket"></param>
/// <param name="size">The number of bytes to receive.</param>
/// <param name="timeout">Specifies the amount of time after which the call will time out.</param>
/// <returns>
/// The bytes received.
/// </returns>
/// <remarks>
/// If no data is available for reading, the <see cref="Read(Socket, int, TimeSpan)"/> method will
/// block until data is available or the time-out value is exceeded. If the time-out value is exceeded, the
/// <see cref="Read(Socket, int, TimeSpan)"/> call will throw a <see cref="SshOperationTimeoutException"/>.
/// If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, the
/// <see cref="Read(Socket, int, TimeSpan)"/> method will complete immediately and throw a <see cref="SocketException"/>.
/// </remarks>
public static byte[] Read(Socket socket, int size, TimeSpan timeout)
{
var buffer = new byte[size];
Read(socket, buffer, 0, size, timeout);
return buffer;
}

/// <summary>
/// Receives data from a bound <see cref="Socket"/> into a receive buffer.
/// </summary>
/// <param name="socket"></param>
/// <param name="buffer">An array of type <see cref="byte"/> that is the storage location for the received data. </param>
Expand All @@ -289,11 +312,11 @@ public static void SendByte(Socket socket, byte value)
/// The number of bytes received.
/// </returns>
/// <remarks>
/// If no data is available for reading, the <see cref="Read(Socket,byte[], int, int, TimeSpan)"/> method will
/// block until data is available or the time-out value was exceeded. If the time-out value was exceeded, the
/// <see cref="Read(Socket,byte[], int, int, TimeSpan)"/> call will throw a <see cref="SshOperationTimeoutException"/>.
/// If no data is available for reading, the <see cref="Read(Socket, byte[], int, int, TimeSpan)"/> method will
/// block until data is available or the time-out value is exceeded. If the time-out value is exceeded, the
/// <see cref="Read(Socket, byte[], int, int, TimeSpan)"/> call will throw a <see cref="SshOperationTimeoutException"/>.
/// If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, the
/// <see cref="Read(Socket,byte[], int, int, TimeSpan)"/> method will complete immediately and throw a <see cref="SocketException"/>.
/// <see cref="Read(Socket, byte[], int, int, TimeSpan)"/> method will complete immediately and throw a <see cref="SocketException"/>.
/// </remarks>
public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeSpan timeout)
{
Expand Down

0 comments on commit 7b43bdc

Please sign in to comment.