コード例 #1
0
ファイル: HttpClient.cs プロジェクト: vstion/12306_Helper
 ///<summary>Called when we send TYPE command.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnPasvConnected(IAsyncResult ar)
 {
     try
     {
         DestinationSocket.EndConnect(ar);
         string rq = "TYPE I\r\n";
         DestinationFtpSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnTypeQuerySent), DestinationFtpSocket);
     }
     catch
     {
         Dispose();
     }
 }
コード例 #2
0
ファイル: HttpClient.cs プロジェクト: vstion/12306_Helper
        ///<summary>Called when we received the REST response.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnRestQuerySent(IAsyncResult ar)
        {
            try
            {
                if (DestinationFtpSocket.EndSend(ar) == -1)
                {
                    Dispose();
                    return;
                }

                DestinationFtpSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnRestQueryRecv), DestinationFtpSocket);
            }
            catch
            {
                Dispose();
            }
        }
コード例 #3
0
ファイル: HttpClient.cs プロジェクト: vstion/12306_Helper
        ///<summary>Called when we begin receive the data.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnFtpQuerySent(IAsyncResult ar)
        {
            try
            {
                if (DestinationFtpSocket.EndSend(ar) == -1)
                {
                    Dispose();
                    return;
                }


                StartRelay();
            }
            catch
            {
                Dispose();
            }
        }
コード例 #4
0
ファイル: HttpClient.cs プロジェクト: vstion/12306_Helper
        ///<summary>Called when we send the REST command.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnTypeQueryRecv(IAsyncResult ar)
        {
            try
            {
                int ret = DestinationFtpSocket.EndReceive(ar);
                if (ret == -1)
                {
                    Dispose();
                    return;
                }

                string rq = "REST 0\r\n";
                DestinationFtpSocket.BeginSend(Encoding.ASCII.GetBytes(rq), 0, rq.Length, SocketFlags.None, new AsyncCallback(this.OnRestQuerySent), DestinationFtpSocket);
            }
            catch
            {
                Dispose();
            }
        }
コード例 #5
0
ファイル: HttpClient.cs プロジェクト: vstion/12306_Helper
        ///<summary>Called when we receive the download port.</summary>
        ///<param name="ar">The result of the asynchronous operation.</param>
        private void OnFtpPasvQueryRecv(IAsyncResult ar)
        {
            try
            {
                int ret = DestinationFtpSocket.EndReceive(ar);
                if (ret == -1)
                {
                    Dispose();
                    return;
                }

                IPEndPoint ConnectTo = ParsePasvIP(Encoding.ASCII.GetString(Buffer, 0, ret));
                DestinationSocket = new Socket(ConnectTo.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                DestinationSocket.BeginConnect(ConnectTo, new AsyncCallback(this.OnPasvConnected), DestinationSocket);
            }
            catch
            {
                Dispose();
            }
        }