/// <summary> /// 释放资源 /// </summary> public override void Dispose() { if (IsDisposed == 0) { base.Dispose(); DisposeSocket(); SocketWait.Set(); } }
private void createSocket(IPAddress ipAddress, int port, int createVersion) { if (check(ipAddress, port)) { CreateSocket = new ClientSocket(this, ipAddress, port, createVersion); } else { SocketWait.Set(); } }
/// <summary> /// 释放资源 /// </summary> public override void Dispose() { if (IsDisposed == 0) { base.Dispose(); if (CreateSocket != null) { (CreateSocket as ClientSocket <attributeType>).DisposeSocket(); } SocketWait.Set(); } }
/// <summary> /// 尝试创建第一个套接字 /// </summary> public void TryCreateSocket() { if (Interlocked.CompareExchange(ref CreateVersion, 1, 0) == 0) { IPAddress ipAddress = IpAddress; int port = Port; if (check(ipAddress, port)) { CreateSocket = new ClientSocket(this, ipAddress, port, 1); } else { SocketWait.Set(); } } }