Using phpseclib to close a Net_SFTP connection
Asked Answered
F

1

7

I have a program written in PHP that distributes files to various FTP sites. Recently, I added SFTP support to it using phpseclib. It's very easy to use to log in and upload the files.

However, there doesn't seem to be an explicit function to close a connection. This is important to me because I'm dealing with connecting /disconnecting to a number of sites during the processing.

How can I close a Net_SFTP connection?

Flatling answered 23/4, 2015 at 16:24 Comment(0)
F
11

Does undefining your connection work (as mentioned in this Perl 5 example)?

unset($sftp);  

where $sftp is the variable holding your connection.

Featureless answered 23/4, 2015 at 16:41 Comment(2)
The destructor will log you out. You can also do $sftp->disconnect().Ransome
@Ransome By "The destructor will log you out." do you mean "Whenever $sftp goes out of scope, it will automatically close the connection"?Featureless

© 2022 - 2024 — McMap. All rights reserved.