/// <summary> /// 进行数据连接 /// </summary> /// <param name="port"></param> /// <returns></returns> public async Task Connect( [SuitParser(typeof(Parsers), nameof(Parsers.ParseInt))] int port) { DataStream = await RdtStream.CreateClientAsync( Config, new IPEndPoint(Ip, port)); await IO.WriteLineAsync($"Connect {DataStream?.Port ?? -1}"); }
public async Task Connect( [SuitParser(typeof(LftpClient), nameof(ParseIp))] IPAddress ip, [SuitParser(typeof(Parsers), nameof(Parsers.ParseInt))] int port) { if (Controller != null) { await Controller.WriteLineAsync("Exit"); } ControllerStream = await RdtStream.CreateClientAsync( Config, new IPEndPoint(ip, port)); if (ControllerStream == null) { await IO.WriteLineAsync($"连接服务器失败。"); return; } Controller = new StreamWriter(ControllerStream) { AutoFlush = true }; var cc = new LftpClientController(Config); Task.Run(() => { Suit.GetBuilder() .ConfigureIn(new StreamReader(ControllerStream)) .UseLog(ILogger.OfFile($"ClientController-{cc.ListenerPort}.log")) .Build(cc) .Run(); }).GetAwaiter(); await Controller.WriteLineAsync($"Connect {cc.ListenerPort}"); }