IRC "QUIT" not working properly

CHANGE: I have determined the problem has nothing to do with the coding. However the problem stays still, as this appears to be caused by IRC, I'm still in search of the reason.

The server I'm connecting uses two kinds of PING requests:

One is asked upon connecting to server, and it's in format of alpha-numeric values of 8 characters.

Example: PING :EA0E9275.

And another one is after the server sends out MOTD, joins channels, completes "End of /NAMES list". Then after "n delay" server sends me a ping request with current connected host as it's value.

Example: PING :irc.ams.nl.euirc.net

If I send the command "QUIT :Quit Message" before I reply the host PING request, server ignores the QUIT message, and instead, it quits with a server-filled status message similiar to "Client Exited" message.

Example: ERROR :Closing Link: Nick[IP.ADD.RE.SS] (Life is too short...)

However if I send the same command after responding to host PING request, my QUIT gets processed as it should.

Example: ERROR :Closing Link: Nick[IP.ADD.RE.SS] (Quit: Quit Message)

I've checked in the RFC, and found this on QUIT section:

If, for some other reason, a client connection is closed without the client issuing a QUIT command (eg client dies and EOF occurs on socket), the server is required to fill in the quit message with some sort of message reflecting the nature of the event which caused it to happen.

Also, if still in need to see the partial code I'm using to accomplish this, you can check it here. However, this is a common issue with mIRC the IRC client.

Basic scheme

  • Connecting to server...
  • Connected!
  • Server waiting NICK/USER info...
  • Server received NICK/USER info, waiting for alphanumeric PING reply...
  • Server received alphanumeric PING reply, sending MOTD.
  • End of MOTD, sending JOIN to join channels...
  • Joined to channels, NAMES list for channels have been requested.
  • End of NAMES list.
  • Receiving active channel(s)/server data.
  • If sent QUIT command, server will ignore the usual QUIT, and will send "Closing Link" by server default as status quit(Life is too short...).
  • Server is doing an alive-check, received host PING(irc.ams.nl.euirc.net), server is waiting reply...
  • Sent server the reply.
  • If sent QUIT command, server will process QUIT command as user-level, the usual way, and will send "Closing Link" by user-specified message or empty.((QUIT: User Message) or (QUIT: ))

  • Let's review your code for a bit:

  • When I made my IRC bot, I explode() ed the string from the server into words (splitting by space), you can then refer to words:

    if ($words[0] == "PING") { reply("PONG :" . $words[1]); }
    
  • Always PONG immediately after PING , and reply with the same message as the server.

  • If the second is fulfilled, you should never have that problem of the server waiting a PING, because you'll immediately answer. A client is expected to honor the PING PONG commands from the server, otherwise the server would think of it as offline (yes, even if you send anything else, the server expects PONG).

    链接地址: http://www.djcxy.com/p/53460.html

    上一篇: 从多个套接字读取(irc bot)

    下一篇: IRC“QUIT”无法正常工作