Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

How long can IRC messages be?

The IRC protocol (RFC 1459 § 2.3) limits a single line to 512 bytes including two "end of line" characters, which leaves 510 bytes usable for commands and text.

When you send a message, it looks like:

PRIVMSG #freenode :Hello everyone!

And other users receive something like:

:grawity!grawity@nullroute.eu.org PRIVMSG #freenode :Hello everyone!

All of this must fit within 510 bytes plus the end-of-line characters \r\n.

So the maximal message length can be calculated like this:

message = 512 - len(":" + nick + "!" + user + "@" + host + " PRIVMSG " + channel + " :" + CR LF)

Or in other words,

message = 496 - len(nick + user + host + channel)

For example:

  • Your nickname is nick [4 bytes]
  • You are connecting from ident@hostname [5 + 8 bytes]
  • You send a message to #example [8 bytes]
  • The longest message you can send is 496 - (4 + 5 + 8 + 8) = 471 bytes.

RFC 1459 § 2.3:

IRC messages are always lines of characters terminated with a CR-LF (Carriage Return - Line Feed) pair, and these messages shall not exceed 512 characters in length, counting all characters including the trailing CR-LF. Thus, there are 510 characters maximum allowed for the command and its parameters. There is no provision for continuation message lines. See section 7 for more details about current implementations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment