BOB/DeviceCommand/Base/ITCP.cs
2025-11-20 13:42:13 +08:00

26 lines
726 B
C#

using System;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceCommand.Base
{
public interface ITcp
{
public TcpClient TcpClient { get; set; }
Task<bool> ConnectAsync(CancellationToken ct = default);
void Close();
Task SendAsync(byte[] buffer, CancellationToken ct = default);
Task SendAsync(string str, CancellationToken ct = default);
Task<byte[]> ReadAsync(int length, CancellationToken ct = default);
Task<string> ReadAsync(string delimiter = "\n", CancellationToken ct = default);
Task<string> WriteReadAsync(string command, string delimiter = "\n", CancellationToken ct = default);
}
}