Browse Source

Socket.ConnectAsync() does not call SocketAsyncEventArgs.Completed when operation completed synchronously.

#1273
tags/4.0.5
celeron533 7 years ago
parent
commit
0251130fa5
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      shadowsocks-csharp/Util/Sockets/WrappedSocket.cs

+ 4
- 1
shadowsocks-csharp/Util/Sockets/WrappedSocket.cs View File

@@ -42,7 +42,10 @@ namespace Shadowsocks.Util.Sockets
arg.Completed += OnTcpConnectCompleted; arg.Completed += OnTcpConnectCompleted;
arg.UserToken = new TcpUserToken(callback, state); arg.UserToken = new TcpUserToken(callback, state);


Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, arg);
if(!Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, arg))
{
OnTcpConnectCompleted(this, arg);
}
} }


private class FakeAsyncResult : IAsyncResult private class FakeAsyncResult : IAsyncResult


Loading…
Cancel
Save