/// <summary> /// 修改配置 /// </summary> public void Config() { var newConfig = new RdtConfig { PackageLoss = int.Parse(IO.ReadLine("丢包率/百分比[0-100]", RdtConfig.PackageLoss.ToString()) ?? "0"), SendRangeLength = sbyte.Parse(IO.ReadLine("发送区间长度[1-125]", RdtConfig.SendRangeLength.ToString()) ?? "60"), DiagramMaxLength = ushort.Parse(IO.ReadLine("最大报文长度[1-65534]", RdtConfig.DiagramMaxLength.ToString()) ?? "60000"), SendTimeout = int.Parse(IO.ReadLine("发送超时界限[100-1000]", RdtConfig.SendTimeout.ToString()) ?? "200") }; if (newConfig.Check()) { RdtConfig = newConfig; IO.WriteLine("配置修改成功,重启后生效。"); } else { IO.WriteLine("配置修改失败。"); } }
public LftpClient(RdtConfig config) { //Ip = endPoint?.Address ?? IPAddress.Loopback; Config = config; }
public LftpClientController(RdtConfig config) { Listener = RdtStream.CreateListener(config); //Ip = endPoint?.Address ?? IPAddress.Loopback; Config = config; }
public LftpServerController(IPEndPoint?endPoint, RdtConfig config) { Ip = endPoint?.Address ?? IPAddress.Loopback; Config = config; }
public LftpServer(RdtConfig config, int port = 0) { Listener = RdtStream.CreateListener(config, port); Config = config; Run().GetAwaiter(); }
public static bool WillLose(this RdtConfig config) { return(Random.Next(100) < config.PackageLoss); }