Commit 862b1d92 authored by justcoding121's avatar justcoding121

check for client/socket Connected

parent 1adcd863
...@@ -88,8 +88,8 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -88,8 +88,8 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
while (existingConnections.TryDequeue(out var recentConnection)) while (existingConnections.TryDequeue(out var recentConnection))
{ {
//+1 seconds for potential delay after getting connection //+3 seconds for potential delay after getting connection
var cutOff = DateTime.Now.AddSeconds((-1 * proxyServer.ConnectionTimeOutSeconds) + 1); var cutOff = DateTime.Now.AddSeconds((-1 * proxyServer.ConnectionTimeOutSeconds) + 3);
if (recentConnection.LastAccess > cutOff if (recentConnection.LastAccess > cutOff
&& IsGoodConnection(recentConnection.TcpClient)) && IsGoodConnection(recentConnection.TcpClient))
...@@ -333,6 +333,12 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -333,6 +333,12 @@ namespace Titanium.Web.Proxy.Network.Tcp
private static bool IsGoodConnection(TcpClient client) private static bool IsGoodConnection(TcpClient client)
{ {
var socket = client.Client; var socket = client.Client;
if (!client.Connected || socket.Connected)
{
return false;
}
// This is how you can determine whether a socket is still connected. // This is how you can determine whether a socket is still connected.
bool blockingState = socket.Blocking; bool blockingState = socket.Blocking;
try try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment