ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link

[question] What is the advantage of using a Session? #20

Closed ontytoom closed 8 years ago

ontytoom commented 8 years ago

(I don't see any way to ask a question, so I am putting this into an issue, but it's really a request for info.)

What is the advantage for using a session? The documentation on the main page shows me how to make a session, but does not explain what is useful about it.

In case you are curious how I am using your library, please see https://github.com/ontytoom/AntonFtpClient

picrap commented 8 years ago

This is a good question :smile: The FTP client is divided into two parts:

So you can have multiple FtpSessions running at the same time, typically for parallel transfers, where each session handles a single transfer. The FTP client allows also to work without having to use sessions directly (the FtpClientUtility class does this by implementing common commands). If you don't feel the need to use sessions, then this means you don't need them. But you'll probably feel that need if you want to implement parallel transfers :wink: Does this help?

ontytoom commented 8 years ago

Thank you, this is a rather helpful explanation.

So far I have had multiple concurrent connections to the FTP server by making multiple instances of the FtpClient class. In my app, I have a browse window and a recursive analysis window. Each of them uses a separate FtpClient instance, because I thought it helps with concurrency. In the previous versions of my app they used to share the same FtpClient instance, but then analysis would pause for a moment when the user is browsing interactively. To solve this, I made multiple instances of FtpClient class.

Do you think my approach is equivalent to using FtpSession?

picrap commented 8 years ago

Yes, it is equivalent.

ontytoom commented 8 years ago

I see. Thank you for the info.