Util/TcpClient.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace Util
{
public class TcpClient : IDisposable
{
private System.Net.Sockets.TcpClient Client = new System.Net.Sockets.TcpClient();
private NetworkStream TcpStream;
private byte[] FixedBuffer;
private int BufferSize;
private bool ConnectState = false;
private readonly object LockHandler = new object();
private bool MonitoringThreadActive = true;
private Thread IncomingDataMonitoring = null;
private Thread ConnectionMonitoring = null;
public bool SuspendDataReceivedEvent { get; set; } = false;
public event EventHandler<TcpDataReceivedEventArgs> DataReceived;
public event EventHandler ConnectionStatusChanged;
public string HostName { get; set; }
public int Port { get; set; }
public int ReadTimeout { get; set; } = 1000;
public TcpClient() { }
public TcpClient(string hostName, int port)
{
HostName = hostName;
Port = port;
}
public bool Connected
{
get
{
bool state = Client.Connected;
if (state == ConnectState) return ConnectState;
ConnectState = state;
if (!ConnectState) TerminateThreadsAndTCPStream();
ConnectionStatusChanged?.Invoke(this, null);
return state;
}
private set
{
if (value == ConnectState) return;
ConnectState = value;
ConnectionStatusChanged?.Invoke(this, null);
}
}
public virtual void Connect()
{
Disconnect();
后面还有 204 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。