You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

1 year ago
using System.Net.Sockets;
namespace JiLinApp.Docking.VibrateAlarm;
public class TcpClientState
{
/// <summary>
/// Constructor for a new Client
/// </summary>
/// <param name="client">The TCP client</param>
1 year ago
/// <param name="buffer">The byte array buffer</param>
public TcpClientState(TcpClient client, byte[] buffer)
1 year ago
{
if (client == null) throw new ArgumentNullException("tcpClient");
1 year ago
if (buffer == null) throw new ArgumentNullException("buffer");
Client = client;
1 year ago
Buffer = buffer;
Temp = string.Empty;
1 year ago
}
/// <summary>
/// Gets the TCP Client
/// </summary>
public TcpClient Client { get; private set; }
1 year ago
/// <summary>
/// Gets the Buffer.
/// </summary>
public byte[] Buffer { get; private set; }
/// <summary>
/// TCP接收到但未处理的数据
/// </summary>
public string Temp { get; set; }
1 year ago
/// <summary>
/// Gets the network stream
/// </summary>
public NetworkStream GetStream
1 year ago
{
get
{
NetworkStream stream = Client.GetStream();
stream.ReadTimeout = 5000;
stream.WriteTimeout = 5000;
return stream;
1 year ago
}
}
public bool IsRead { get; set; }
public object IsReadLock { get; } = new();
1 year ago
}