ftp_close() vs. ftp_quit()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Markus

    ftp_close() vs. ftp_quit()

    Hi

    I encountered that FTP connections seem to remain open on the FTP
    server, though my FTP class has a shutdown function that ftp_quit()s the
    connection.

    I did not find any info in the manual regarding the differences of
    ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
    close, then quit? Is it possible that ftp_quit() does not close the
    connection on the FTP server? Or do I have to look for something else?

    Thanks for some hints!
    Markus
  • purcaholic

    #2
    Re: ftp_close() vs. ftp_quit()

    On 21 Mai, 13:34, Markus <derernst@NO#SP #AMgmx.chwrote:
    Hi
    >
    I encountered that FTP connections seem to remain open on the FTP
    server, though my FTP class has a shutdown function that ftp_quit()s the
    connection.
    >
    I did not find any info in the manual regarding the differences of
    ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
    close, then quit? Is it possible that ftp_quit() does not close the
    connection on the FTP server? Or do I have to look for something else?
    >
    Thanks for some hints!
    Markus

    Hi,

    ftp_close() and ftp_quit() do the same job, ftp_quit() is an alias of
    ftp_close().

    The function ftp_close() needs the connetion ressource id as parameter
    to close a earlier opened connection. Maybe you call ftp_close without
    a ressource id or with a wrong ressource id, this could be a reason of
    remained ftp connections.

    purcaholic

    Comment

    • Markus

      #3
      Re: ftp_close() vs. ftp_quit()

      purcaholic schrieb:
      On 21 Mai, 13:34, Markus <derernst@NO#SP #AMgmx.chwrote:
      >Hi
      >>
      >I encountered that FTP connections seem to remain open on the FTP
      >server, though my FTP class has a shutdown function that ftp_quit()s the
      >connection.
      >>
      >I did not find any info in the manual regarding the differences of
      >ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
      >close, then quit? Is it possible that ftp_quit() does not close the
      >connection on the FTP server? Or do I have to look for something else?
      >>
      >Thanks for some hints!
      >Markus
      >
      >
      Hi,
      >
      ftp_close() and ftp_quit() do the same job, ftp_quit() is an alias of
      ftp_close().
      Thank you for this info. It is bad news for me, as it does contradict my
      assumptions regarding my actual problem. Anyway both functions seem to
      be wrongly documented in the manual:

      void ftp_close ( resource $ftp_stream )
      int ftp_quit ( int $ftp_stream )

      As the signatures differ, they do not really seem to be aliases of one
      another. But actually they seem to behave the same, both not according
      to the manual: var_dump(ftp_cl ose($conn_id)) and
      var_dump(ftp_qu it($conn_id)) both display bool(true)... I filed a bug
      about this.

      Anyway: Is there a possibility to find out whether a connection has been
      terminated on the FTP server side, too? (I mean, besides asking the ISP
      to give me access to log files.)

      Comment

      • Schraalhans Keukenmeester

        #4
        Re: ftp_close() vs. ftp_quit()

        At Mon, 21 May 2007 13:34:50 +0200, Markus let his monkeys type:
        Hi
        >
        I encountered that FTP connections seem to remain open on the FTP
        server, though my FTP class has a shutdown function that ftp_quit()s the
        connection.
        >
        I did not find any info in the manual regarding the differences of
        ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
        close, then quit? Is it possible that ftp_quit() does not close the
        connection on the FTP server? Or do I have to look for something else?
        >
        Thanks for some hints!
        Markus
        How exactly did you assert the connection wasn't closed after ftp_close()?
        Just tried it on my localhost and my isp's server, in both cases the
        connection is closed according to the vsftpd log (localhost) and the Plesk
        Control Panel (isp).

        Where did you find the types involved with ftp_quit()?
        The dutch php manual mirrors don't give any return and parameter
        type for ftp_quit():



        Sh.

        Comment

        • Markus

          #5
          Re: ftp_close() vs. ftp_quit()

          Schraalhans Keukenmeester schrieb:
          At Mon, 21 May 2007 13:34:50 +0200, Markus let his monkeys type:
          >
          >Hi
          >>
          >I encountered that FTP connections seem to remain open on the FTP
          >server, though my FTP class has a shutdown function that ftp_quit()s the
          >connection.
          >>
          >I did not find any info in the manual regarding the differences of
          >ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
          >close, then quit? Is it possible that ftp_quit() does not close the
          >connection on the FTP server? Or do I have to look for something else?
          >>
          >Thanks for some hints!
          >Markus
          >
          How exactly did you assert the connection wasn't closed after ftp_close()?
          Just tried it on my localhost and my isp's server, in both cases the
          connection is closed according to the vsftpd log (localhost) and the Plesk
          Control Panel (isp).
          It is a guess. I located the delays in the PHP script in the ftp login
          command, and I encountered the same delays connecting to the ftp server
          with FileZilla, and the delays occur only after the PHP script had been
          running some times. So my conclusion was that something in my script
          slows down the ftp server; I don't know much about ftp, and assumed this
          could possibly be open connections that are only closed after the
          timeout period. I will ask my ISP how to access the ftp log to find out
          more.
          Where did you find the types involved with ftp_quit()?
          The dutch php manual mirrors don't give any return and parameter
          type for ftp_quit():

          http://nl2.php.net/manual/en/function.ftp-close.php
          Yes I also found the correct documentations in the english version of
          the manual; the errors are in the german version. Sorry for this badly
          researched statement.

          Comment

          • =?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=

            #6
            Re: ftp_close() vs. ftp_quit()

            Markus wrote:
            purcaholic schrieb:
            On 21 Mai, 13:34, Markus <derernst@NO#SP #AMgmx.chwrote:
            Hi
            >
            I encountered that FTP connections seem to remain open on the FTP
            server, though my FTP class has a shutdown function that
            ftp_quit()s the connection.
            >
            I did not find any info in the manual regarding the differences of
            ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even
            first close, then quit? Is it possible that ftp_quit() does not
            close the connection on the FTP server? Or do I have to look for
            something else?
            >
            Thanks for some hints!
            Markus

            Hi,

            ftp_close() and ftp_quit() do the same job, ftp_quit() is an alias
            of ftp_close().
            >
            Thank you for this info. It is bad news for me, as it does contradict
            my assumptions regarding my actual problem. Anyway both functions
            seem to be wrongly documented in the manual:
            >
            void ftp_close ( resource $ftp_stream )
            int ftp_quit ( int $ftp_stream )
            >
            As the signatures differ, they do not really seem to be aliases of
            one another. But actually they seem to behave the same, both not
            according to the manual: var_dump(ftp_cl ose($conn_id)) and
            var_dump(ftp_qu it($conn_id)) both display bool(true)... I filed a bug
            about this.
            Which manual have you been reading? These are the only official manual
            entries for ftp_quit() and ftp_close():



            Both should, and they do, return a boolean value (TRUE on success or
            FALSE on failure) according to your own tests (and since ftp_quit() is
            an alias for ftp_close(), there shouldn't be a difference, either).
            Anyway: Is there a possibility to find out whether a connection has
            been terminated on the FTP server side, too? (I mean, besides asking
            the ISP to give me access to log files.)
            There's no way of telling, much like there's no way of telling whether
            the connection to a web server was properly closed on the server side
            after you've visited a website.

            The only way of telling whether a connection has been terminated on the
            server side, is to ask the administrator or owner of the server you're
            connecting to.

            --
            Kim André Akerø
            - kimandre@NOSPAM betadome.com
            (remove NOSPAM to contact me directly)

            Comment

            • ED

              #7
              Re: ftp_close() vs. ftp_quit()


              "Markus" <derernst@NO#SP #AMgmx.chwrote in message
              news:46517c0c$1 _2@news.cyberci ty.ch...
              Hi
              >
              I encountered that FTP connections seem to remain open on the FTP server,
              though my FTP class has a shutdown function that ftp_quit()s the
              connection.
              >
              I did not find any info in the manual regarding the differences of
              ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
              close, then quit? Is it possible that ftp_quit() does not close the
              connection on the FTP server? Or do I have to look for something else?
              >
              Thanks for some hints!
              Markus

              hi Markus,

              Just a thought, but maybe try sending an FTP QUIT command to the server
              before closing the conn - it may give the server the hint to close its
              connection(s):

              ftp_raw($ftpcon n, 'QUIT');
              ftp_close($ftpc onn);

              cheers,
              ED


              Comment

              • Markus

                #8
                Re: ftp_close() vs. ftp_quit()

                ED schrieb:
                "Markus" <derernst@NO#SP #AMgmx.chwrote in message
                news:46517c0c$1 _2@news.cyberci ty.ch...
                >Hi
                >>
                >I encountered that FTP connections seem to remain open on the FTP server,
                >though my FTP class has a shutdown function that ftp_quit()s the
                >connection.
                >>
                >I did not find any info in the manual regarding the differences of
                >ftp_close() and ftp_quit(). Do I have to use ftp_close()? Or even first
                >close, then quit? Is it possible that ftp_quit() does not close the
                >connection on the FTP server? Or do I have to look for something else?
                >>
                >Thanks for some hints!
                >Markus
                >
                >
                hi Markus,
                >
                Just a thought, but maybe try sending an FTP QUIT command to the server
                before closing the conn - it may give the server the hint to close its
                connection(s):
                >
                ftp_raw($ftpcon n, 'QUIT');
                ftp_close($ftpc onn);
                Thank you, good point! As ftp_raw() is PHP5 only and the application is
                supposed to run from PHP 4.3 upwards, I added reduction of the timeout
                period, so the number of possibly open connections on the server should
                be reduced to a reasonable amount:

                if (function_exist s('ftp_raw')) {
                ftp_raw($ftpcon n, 'QUIT');
                }
                else {
                ftp_set_option( $ftpconn, FTP_TIMEOUT_SEC , 1);
                }
                ftp_close($ftpc onn);

                Comment

                Working...