By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,066 Members | 1,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,066 IT Pros & Developers. It's quick & easy.

ftp_close() vs. ftp_quit()

P: n/a
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
May 21 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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

May 21 '07 #2

P: n/a
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_close($conn_id)) and
var_dump(ftp_quit($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.)
May 21 '07 #3

P: n/a
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():
http://nl2.php.net/manual/en/function.ftp-quit.php
http://nl2.php.net/manual/en/function.ftp-close.php

Sh.
May 21 '07 #4

P: n/a
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-quit.php
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.
May 21 '07 #5

P: n/a
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_close($conn_id)) and
var_dump(ftp_quit($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():
http://php.net/ftp_quit
http://php.net/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ĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
May 21 '07 #6

P: n/a
ED

"Markus" <derernst@NO#SP#AMgmx.chwrote in message
news:46**********@news.cybercity.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($ftpconn, 'QUIT');
ftp_close($ftpconn);

cheers,
ED
May 22 '07 #7

P: n/a
ED schrieb:
"Markus" <derernst@NO#SP#AMgmx.chwrote in message
news:46**********@news.cybercity.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($ftpconn, 'QUIT');
ftp_close($ftpconn);
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_exists('ftp_raw')) {
ftp_raw($ftpconn, 'QUIT');
}
else {
ftp_set_option($ftpconn, FTP_TIMEOUT_SEC, 1);
}
ftp_close($ftpconn);
May 22 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.