tcping增加5s超时机制; ping间隔降低至10ms

pull/453/head
YFdyh000 5 years ago
parent 6206c81546
commit 1b0e3b3575

@ -977,9 +977,9 @@ namespace v2rayN.Forms
} }
private void ClearTestResult() private void ClearTestResult()
{ {
for (int k = 0; k < lvSelecteds.Count; k++) foreach (int s in lvSelecteds)
{ {
SetTestResult(lvSelecteds[k], ""); SetTestResult(s, "");
} }
} }
private void UpdateSpeedtestHandler(int index, string msg) private void UpdateSpeedtestHandler(int index, string msg)

@ -103,9 +103,8 @@ namespace v2rayN.Handler
{ {
try try
{ {
for (int k = 0; k < _selecteds.Count; k++) foreach (int index in _selecteds)
{ {
int index = _selecteds[k];
if (_config.vmess[index].configType == (int)EConfigType.Custom) if (_config.vmess[index].configType == (int)EConfigType.Custom)
{ {
continue; continue;
@ -121,7 +120,7 @@ namespace v2rayN.Handler
} }
} }
Thread.Sleep(100); Thread.Sleep(10);
} }
catch (Exception ex) catch (Exception ex)
@ -262,8 +261,14 @@ namespace v2rayN.Handler
var timer = new Stopwatch(); var timer = new Stopwatch();
timer.Start(); timer.Start();
Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var endPoint = new IPEndPoint(ipAddress, port);
clientSocket.Connect(new IPEndPoint(ipAddress, port)); Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5)))
throw new TimeoutException("connect timeout (5s): " + url);
clientSocket.EndConnect(result);
timer.Stop(); timer.Stop();
responseTime = timer.Elapsed.Milliseconds; responseTime = timer.Elapsed.Milliseconds;
clientSocket.Close(); clientSocket.Close();

Loading…
Cancel
Save