public void Connect() { for (int i = 0; i < MaxConnections; i++) { var packet = new Packets.ClientPacket(); packet.Options = Options; AsyncTcpClient client; if (mSslServerName == null) { client = BeetleX.SocketFactory.CreateClient <BeetleX.Clients.AsyncTcpClient>( packet, Host, Port); } else { client = BeetleX.SocketFactory.CreateSslClient <BeetleX.Clients.AsyncTcpClient>( packet, Host, Port, mSslServerName); } client.PacketReceive = OnPacketCompleted; client.ClientError = (c, e) => { NetError?.Invoke(c, e); }; mClients.Add(client); } }
private void RaiseOtherException(AsyncSocketState state) { if (NetError != null) { NetError.Invoke(this, new AsyncSocketEventArgs(state)); } }
private void OnError(IClient client, ClientErrorArgs e) { try { NetError.Invoke(client, e); } catch { } }
/// <summary> /// 触发网络错误事件 /// </summary> /// <param name="state"></param> private void RaiseNetError(AsyncUDPState state, Exception exception) { NetError?.Invoke(this, new ScadaUDPEventArgs(exception, state)); }
/// <summary> /// 触发网络错误事件 /// </summary> /// <param name="state"></param> private void RaiseNetError(AsyncSocketState state) { NetError?.Invoke(this, new AsyncSocketEventArgs(state)); }