예제 #1
0
        private void ReleaseSocketArgs(SocketAsyncEventArgs args)
        {
            if (args != null)
            {
                args.Completed -= OnSocketCompleted; // clear previously attached event.

                // On Microsoft's AcceptSocket page, it says,
                // "If not supplied (set to null) before calling the Socket.AcceptAsync method, a new socket will be created automatically."
                // The "new socket is constructed with the same AddressFamily, SocketType, and ProtocolType as the current socket",
                // which is the listening socket.
                args.AcceptSocket = null;
                args.UserToken    = null;

                SocketPool.Push(args);
            }
        }