コード例 #1
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();
            }
        }
コード例 #2
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();
            }
        }