473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
May 21 '07 #1
7 3599
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mathias Koerber | last post by:
Hi, I am quite new to PHP (but have experience with perl etc) and am facing a certain issue with PHP 4.2.1's ftp function. I am trying to extend a program to fetch a file from a remote server....
1
by: Piotr Szumny | last post by:
Hi! I wrote class for sending files via FTP. I hvae problem when I try to use it. I see this message: Warning: ftp_put() expects parameter 1 to be resource, boolean given in...
3
by: Alain Dhaene | last post by:
HI, I have follow problem. I want upload a file to a map on a ftp server. I make a connection to a ftp server. That's ok. Then I make a directory ftp_chdir($conn_id,"/public_html/info"); ...
0
by: D Elkins | last post by:
I am trying to write a small web interface to allow users to upload a zip file to our server. Below is code: //The form <FORM action="ftp_upload.php" method=post enctype="multipart/form-data">...
2
by: Felix Natter | last post by:
hi, I am using ftp_connect with php 4.1.x, and the manual states that ftp_close should be used to close the connection when done, but it is only available in php >= 4.2.0. What should I do...
1
by: Felix Natter | last post by:
hi, I would like to upload a file (via a form), then read that (temporary) file and write the contents into a database. The first problem is that open_basedir=/home/CUSTOMER so I can't just read...
0
by: Google Mike | last post by:
Had to write something similar to this for my office. You can adapt to your use. I just put it on a chron job for every 15 minutes. My bash script did: #!/bin/bash php -d...
2
by: Markus Ernst | last post by:
Hi I have a question that I don't find answered in the manual: After opening an ftp connection with PHP, will it be closed automatically after the script is executed, just as MySQL connections...
10
by: Sylvain GRAVERON | last post by:
Hi Sorry I don't speak english very vell and no reply in fr news ! ! ! Bonjour, J'essai d'envoyer par FTP en php un fichier dont le nom, la destination et la source seront toujours les mêmes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.