[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: FTPAPI FTP_exitproc



Hi Scott,

I have followed your suggestion and tested the splitting of FTP_Conn into
FTP_Open / Ftp_Login with the Ftp_ExitProc in between.
That?s works perfect.

Thanks for your help.

Brgds
Helge

-----Oprindelig meddelelse-----
Fra: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] På vegne af Scott Klement
Sendt: 12. februar 2014 22:42
Til: HTTPAPI and FTPAPI Projects
Emne: Re: FTPAPI FTP_exitproc

Helge,

Yes, this is the expected behavior.  when you register an exitProc with
FTP_DEFAULT_SOCKET it will apply to all new connections that are created 
thereafter.    Unless this is what you want, you should not use the 
FTP_DEFAULT_SOCKET.

FTP_Conn() has actually been split into two separate procedures for exactly
this reason.  The new procedures are FTP_Open() which establishes the socket
number, and FTP_Login() which does the login portion of the FTP protocol.
In current versions of FTPAPI, FTP_Conn() actually just calls these two
procedures in succession.

So you should change your code to:

FtpSess  = FTP_Open(FtpRmtSys: FTPPort: FTPCnnTio);

FTP_exitProc( FtpSess: FTP_EXTLOG: %paddr(FTPExitProc): %addr(LastMsg));

if FTP_Login( FtpSess: FtpUsr: FtpPwd ) < 0;
     // error occurred.
endif;

Now the exit procedure will only fire for this particular session, and will
not apply to any others.

You'll want to call FTP_Quit() when this FTP session is done (unless
FTP_open failed for some reason.)



On 2/12/2014 8:53 AM, Helge Bichel wrote:
>     Dear Group.
>
>
>     I have some problems getting the FTP_exitproc working across FTP
>     session within the same 5250 session.
>
>
>     Having:
>
>     (1)          FTP_exitProc( FTP_DEFAULT_SOCKET   : FTP_EXTLOG   :
>     %paddr(FTPExitProc) : %addr(LastMsg) );
>
>     (1)          FtpSess =
>     FTP_Conn(FtpRmtSys:FtpUsr:FtpPwd:FTPPort:FTPCnnTio);
>
>
>     Starting the  FTP_exitproc with FTP_DEFAULT_SOCKET before FTP_conn is
>     for getting the connection message from the FTP server
>
>                     Connecting to host xxx.xxx.xxx.xxx at address
>     xxx.xxx.xxx.xxx using port 21.
>
>                     220 <<<Connect:Enterprise UNIX 2.4.04 Build 134 >>> at
>     espdev01 FTP server ready. Time = 07:19:29
>
>                     > USER
>     yyyyyyyy
>
>                     331 Password required for
>     yyyyyyyy
>
>                     > PASS
>     **********
>
>                     230 Connect:Enterprise UNIX login ok, access
>     restrictions apply.
>
>
>     this would be missing if I used
>
>     (2)          FtpSess =
>     FTP_Conn(FtpRmtSys:FtpUsr:FtpPwd:FTPPort:FTPCnnTio);
>
>     (2)          FTP_exitProc( FtpSess   :  FTP_EXTLOG    :
>     %paddr(FTPExitProc) : %addr(LastMsg) );
>
>
>     Now the problem:
>
>
>     Calling MyFTPPgmA
>
>     Using (1) causes problems if the FTP_Conn for some reason (server not
>     available, invalid pw etc.)  fails.
>
>     The FTP_exitporoc is set at this time and does not get 'cleared'.
>
>     I think this is because I can't do a FTP_Quit since the session isn't
>     established.
>
>
>     Calling MyFTPPgmB
>
>     While still in the same 5250 session I call a different program using
>     the same setup (1) and connecting to another FTP server.
>
>     MyFTPPgmB crashes when doing the FTP_Conn. Reason is the FTP_exitproc
>     still pointing to the routine set by MyFTPPgmA.
>
>     The FTPExitProc in MyFTPPgmA writes to a file  A and  this routine
>     still is in effect when running MyFTPPgmB.
>
>     The required file A isn't open since MyFTPPgmB uses file B, not A..
>
>
>     To summarize the problem:
>
>
>     The FTP_exitproc set in one program 'hangs' when not doing a FTP_Quit
>     and that's seems not to be possible to do when FTP_Conn fails.
>
>
>     Hoping for a wise solution.
>
>
>     Best regards
>
>     Helge
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------


-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------