Ruby Net::IMAP:关闭连接
Ruby Net::IMAP 库为 IMAP 内容提供了一个很好的 API ( http://railsapi.com/doc/ruby-v1.8/classes/Net/IMAP.html)。有两种与关闭 IMAP 连接相关的方法:logout()和disconnect()。他们应该在哪个回合被调用?
Ruby Net::IMAP library provides a good API for IMAP stuff (http://railsapi.com/doc/ruby-v1.8/classes/Net/IMAP.html). There are two methods related to closing the IMAP connection: logout() and disconnect(). In which turn are they supposed to be called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
logout
只会将用户从服务器中注销,而disconnect
将完全关闭套接字。如果您想保持连接打开(例如使用同一套接字登录到另一个邮箱),并在不需要再使用 IMAP 服务器时断开连接,我会使用注销。至于顺序,应在断开连接之前使用注销。logout
will simply log the user out of the server whiledisconnect
will completely close the socket. I would use logout if you want to keep the connection open (like maybe logging into another mailbox using the same socket) and disconnect when you don't need to do anymore work with the IMAP server. As for a sequence, logout should be used before disconnect.