mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
完善因对象已被销毁不能访问的问题
This commit is contained in:
parent
02780363c8
commit
cff0ba7cc8
|
@ -44,18 +44,18 @@ namespace FastTunnel.Core
|
|||
private void swapCallback(object state)
|
||||
{
|
||||
var chanel = state as Channel;
|
||||
byte[] result = new byte[1024];
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] result = new byte[1024];
|
||||
if (!chanel.Receive.Connected)
|
||||
break;
|
||||
int num = chanel.Receive.Receive(result, result.Length, SocketFlags.None);
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
if (chanel.Send.Connected)
|
||||
{
|
||||
chanel.Send.Close();
|
||||
}
|
||||
if (chanel.Receive.Connected)
|
||||
{
|
||||
chanel.Receive.Close();
|
||||
|
@ -63,19 +63,18 @@ namespace FastTunnel.Core
|
|||
break;
|
||||
}
|
||||
|
||||
if (!chanel.Send.Connected)
|
||||
break;
|
||||
chanel.Send.Send(result, num, SocketFlags.None);
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
if (chanel.Send.Connected)
|
||||
chanel.Send.Close();
|
||||
if (chanel.Receive.Connected)
|
||||
chanel.Receive.Close();
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
if (chanel.Receive.Connected)
|
||||
chanel.Receive.Close();
|
||||
|
||||
if (chanel.Send.Connected)
|
||||
chanel.Send.Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user