【问题标题】:Python Irc-Bot EOF from client on socket close and shutdown来自客户端的 Python Irc-Bot EOF 在套接字关闭和关闭时
【发布时间】:2013-11-02 12:34:56
【问题描述】:

我用 Python 做了一个 IRC-Bot。 我想创建一个关机命令。 它看起来像这样:

self.SendMessage("Bye!", self.connectedchannel) # Send bye to the connected channel
self.connection.shutdown(socket.SHUT_RDWR) # Shutdown the socket
self.connection.close() # Close the socket
sys.exit() # Exit the program

但在 IRC 中,机器人会通过“来自客户端的 EOF”断开连接,但无法正确断开连接。 如何更改我的代码呢?

【问题讨论】:

  • 您必须发送QUIT 消息,然后关闭连接。 (不是通过PRIVMSG,我的意思是QUIT :Bye!)
  • 谢谢,这成功了!你能把这个添加为答案吗?

标签: python sockets irc shutdown


【解决方案1】:

在关闭套接字之前,发送QUIT 消息:

QUIT :Bye!

这应该可以解决它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2013-02-17
    相关资源
    最近更新 更多