void UserCmd_End(IAsyncResult ar) { Login_SO stateObj = (Login_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); if (!response.IsCompletionReply && !response.IsIntermediateReply) { throw GetLoginFailedException(response); } if (response.IsCompletionReply) { stateObj.SetCompleted(); } else { _cc.BeginSendCommandEx(stateObj.Timeout, "PASS " + stateObj.Password, new AsyncCallback(PasswordCmd_End), stateObj); } } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } }
void TypeCmd_End(IAsyncResult ar) { RunDTP_SO stateObj = (RunDTP_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); FtpClient.CheckCompletionResponse(response); _client.IsDataTypeWasCached = true; _client.CachedDataType = stateObj.DataType; stateObj.GetDC_Cmd = new Cmd_GetDataConnection(_client); //Initialize data connection stateObj.GetDC_Cmd.BeginExecute(stateObj.Timeout, new AsyncCallback(GetDC_End), stateObj); } catch (Exception e) { HandleCatch(e, stateObj); } catch { HandleCatch(null, stateObj); } }
void SendCmdEx_End(IAsyncResult ar) { Quit_SO stateObj = (Quit_SO)ar.AsyncState; try { stateObj.UpdateContext(); //---------------------------------------- //finish sending command FtpResponse response = _cc.EndSendCommandEx(ar); //---------------------------------------- //Check response FtpClient.CheckCompletionResponse(response); } catch (Exception e) { stateObj.Exception = e; } finally { //---------------------------------------- //Unlock control connection _cc.Unlock(); stateObj.SetCompleted(); } }
void GetDC_EndCmd(IAsyncResult ar) { GetDC_SO stateObj = (GetDC_SO)ar.AsyncState; try { stateObj.UpdateContext(); FtpResponse response = _cc.EndSendCommandEx(ar); if (_passiveMode) { if (false == response.IsCompletionReply) { NSTrace.WriteLineError("PASV: " + response.ToString()); stateObj.Exception = new FtpErrorException("Error while configuring data connection.", response); } else { IPEndPoint ep = GetPasvEndPoint(response); stateObj.DC = new FtpDataConnectionOutbound(_client, ep); } } else { if (false == response.IsCompletionReply) { stateObj.DC.Dispose(); stateObj.DC = null; NSTrace.WriteLineError(stateObj.Cmd + ": " + response.ToString()); stateObj.Exception = new FtpErrorException("Error while configure data connection.", response); } } } catch (Exception e) { stateObj.Exception = e; } stateObj.SetCompleted(); }
internal FtpResponse EndExecute(IAsyncResult ar) { return(_cc.EndSendCommandEx(ar)); }