2 Commits

  1. 9
      Apewer/BytesUtility.cs
  2. 1
      Apewer/Network/TcpServer.cs

9
Apewer/BytesUtility.cs

@ -702,6 +702,15 @@ namespace Apewer
return Read(source, destination, (x) => { progress?.Invoke(x); return true; }, buffer); return Read(source, destination, (x) => { progress?.Invoke(x); return true; }, buffer);
} }
/// <summary>读取流。</summary>
/// <exception cref="ArgumentNullException" />
public static int Read(this Stream stream, byte[] buffer)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
if (buffer == null) throw new ArgumentNullException(nameof(buffer));
return stream.Read(buffer, 0, buffer.Length);
}
/// <summary>读取源流中的数据。</summary> /// <summary>读取源流中的数据。</summary>
/// <param name="source">源流。</param> /// <param name="source">源流。</param>
/// <param name="buffer">缓冲区大小,最小值为 1。</param> /// <param name="buffer">缓冲区大小,最小值为 1。</param>

1
Apewer/Network/TcpServer.cs

@ -93,6 +93,7 @@ namespace Apewer.Network
{ {
if (socket != null) if (socket != null)
{ {
try { socket.Shutdown(SocketShutdown.Both); } catch { }
try { socket.Close(); } catch { } try { socket.Close(); } catch { }
try { socket.Disconnect(false); } catch { } try { socket.Disconnect(false); } catch { }
#if !NET20 #if !NET20

Loading…
Cancel
Save