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

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>
/// <param name="buffer">The byte array buffer</param>
public TcpClientState(TcpClient client, byte[] buffer)
{
if (client == null) throw new ArgumentNullException("tcpClient");
if (buffer == null) throw new ArgumentNullException("buffer");
Client = client;
Buffer = buffer;
Temp = string.Empty;
}
/// <summary>
/// Gets the TCP Client
/// </summary>
public TcpClient Client { get; private set; }
/// <summary>
/// Gets the Buffer.
/// </summary>
public byte[] Buffer { get; private set; }
/// <summary>
/// TCP接收到但未处理的数据
/// </summary>
public string Temp { get; set; }
/// <summary>
/// Gets the network stream
/// </summary>
public NetworkStream GetStream
{
get
{
NetworkStream stream = Client.GetStream();
stream.ReadTimeout = 5000;
stream.WriteTimeout = 5000;
return stream;
}
}
public bool IsRead { get; set; }
public object IsReadLock { get; } = new();
}