12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.IO;
- using System.Net.Sockets;
- using System.Text;
- namespace Team.Communicate.State
- {
- public class TcpClientState
- {
- public TcpClient TcpClient { get; }
- public Encoding Encoding { get; set; }
-
-
-
- public byte[] Buffer { get; private set; }
-
-
-
- public MemoryStream Memory { get; set; }
-
-
-
- public NetworkStream NetworkStream => TcpClient.GetStream();
- public TcpClientState(TcpClient tcpClient, byte[] buffer)
- {
- TcpClient = tcpClient ?? throw new ArgumentNullException(nameof(tcpClient));
- Buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
- Memory = new MemoryStream();
- Encoding=Encoding.Default;
- }
-
-
-
- public void Close()
- {
-
- TcpClient.Close();
- Memory.Close();
- Buffer = null;
- }
- }
- }
|