Beispiel #1
0
        /// <summary>
        /// Provides a wrapper for the async accept operations.
        /// </summary>
        private static void AcceptCallback(IAsyncResult asyncResult)
        {
            FtpControlStream connection   = (FtpControlStream)asyncResult.AsyncState;
            Socket           listenSocket = connection._dataSocket;

            try
            {
                connection._dataSocket = listenSocket.EndAccept(asyncResult);
                if (!connection.ServerAddress.Equals(((IPEndPoint)connection._dataSocket.RemoteEndPoint).Address))
                {
                    connection._dataSocket.Close();
                    throw new WebException(SR.net_ftp_active_address_different, WebExceptionStatus.ProtocolError);
                }
                connection.ContinueCommandPipeline();
            }
            catch (Exception e)
            {
                connection.CloseSocket();
                connection.InvokeRequestCallback(e);
            }
            finally
            {
                listenSocket.Close();
            }
        }
        private static void AcceptCallback(IAsyncResult asyncResult)
        {
            FtpControlStream asyncState  = (FtpControlStream)asyncResult.AsyncState;
            LazyAsyncResult  result      = asyncResult as LazyAsyncResult;
            Socket           asyncObject = (Socket)result.AsyncObject;

            try
            {
                asyncState.m_DataSocket = asyncObject.EndAccept(asyncResult);
                if (!asyncState.ServerAddress.Equals(((IPEndPoint)asyncState.m_DataSocket.RemoteEndPoint).Address))
                {
                    asyncState.m_DataSocket.Close();
                    throw new WebException(SR.GetString("net_ftp_active_address_different"), WebExceptionStatus.ProtocolError);
                }
                asyncState.ContinueCommandPipeline();
            }
            catch (Exception exception)
            {
                asyncState.CloseSocket();
                asyncState.InvokeRequestCallback(exception);
            }
            finally
            {
                asyncObject.Close();
            }
        }
        private static void SSLHandshakeCallback(IAsyncResult asyncResult)
        {
            FtpControlStream asyncState = (FtpControlStream)asyncResult.AsyncState;

            try
            {
                asyncState.ContinueCommandPipeline();
            }
            catch (Exception exception)
            {
                asyncState.CloseSocket();
                asyncState.InvokeRequestCallback(exception);
            }
        }
Beispiel #4
0
        private static void SSLHandshakeCallback(IAsyncResult asyncResult)
        {
            FtpControlStream connection = (FtpControlStream)asyncResult.AsyncState;

            try
            {
                connection._tlsStream.EndAuthenticateAsClient(asyncResult);
                connection.ContinueCommandPipeline();
            }
            catch (Exception e)
            {
                connection.CloseSocket();
                connection.InvokeRequestCallback(e);
            }
        }
Beispiel #5
0
        /// <summary>
        ///    <para>Provides a wrapper for the async accept operations</para>
        /// </summary>
        private static void ConnectCallback(IAsyncResult asyncResult)
        {
            FtpControlStream connection = (FtpControlStream)asyncResult.AsyncState;

            try
            {
                connection._dataSocket.EndConnect(asyncResult);
                connection.ContinueCommandPipeline();
            }
            catch (Exception e)
            {
                connection.CloseSocket();
                connection.InvokeRequestCallback(e);
            }
        }
        private static void ConnectCallback(IAsyncResult asyncResult)
        {
            FtpControlStream asyncState = (FtpControlStream)asyncResult.AsyncState;

            try
            {
                LazyAsyncResult result = asyncResult as LazyAsyncResult;
                ((Socket)result.AsyncObject).EndConnect(asyncResult);
                asyncState.ContinueCommandPipeline();
            }
            catch (Exception exception)
            {
                asyncState.CloseSocket();
                asyncState.InvokeRequestCallback(exception);
            }
        }