CSE 70, Winter 2009

Software Engineering

IRC, Real Raw


Using telnet for a raw IRC session

As with almost all unix-like environments, the ACS lab machines provide a command called telnet that can connect to a network port on a remote host and provide simple bi-directional text-based communication. Since IRC is a simple text-based protocol, telnet is very handy for IRC hackers like us.

It's easy to use; just telnet HOST PORT. You can connect to any host running an IRC server this way; the standard IRC port is 6667. (You can also connect to HTTP servers on port 80, but that's another topic.)

As soon as you connect you'll need to go through IRC connection registration. CAUTION: If you don't do this quickly enough, the server will time out and disconnect. Be prepared to enter something like these messages, examples from RFC 2812:

NICK Wiz
USER guest 0 * :Ronnie Reagan

As you can see this example gives nickname "Wiz", username "guest", and real name "Ronnie Reagan". Once the connection is thus registered successfully the server will immediately send several messages beginning with a RPL_WELCOME like this one:

:irc.example.com 001 Wiz :Welcome to the Internet Relay Network Wiz!~guest@client.example.com

After this you can send raw IRC messages to the server by simply typing them. Messages from the server will be printed, raw, to your terminal. CAUTION: If you receive a message like PING :server.example.com and you don't reply with something like PONG Wiz quickly enough, the server will time out and disconnect.

Note: You won't be able to terminate telnet with Ctrl-C. Normally the best way to terminate an IRC connection is to send a QUIT message to the server. If you haven't supplied the -E option to telnet, then you can also use the escape character (usually Ctrl-]) to return to a telnet prompt. There you can type quit; also try help at the prompt for more information.


Using a relay to capture messages from an IRC session

This is a slightly tricky thing to do, but we've made it quite simple for you by providing a little script. After making sure to prep cs70w, all you need to do is

  1. run relay at a terminal, then
  2. connect an IRC client to localhost port 6667.

The first command sets up a relay from port 6667 on your machine to port 6667 on the class IRC server. After the client connects to the local port—localhost is a standard alias you can use to refer to your computer no matter what its name is—all IRC messages sent in either direction are printed raw to the terminal where relay is running. You can use Ctrl-C at that terminal to kill the relay.

You must be curious how the relay script works. Take a look at its source. It's a very short shell script located at /software/cse-software/bin/relay (as which relay will tell you) and it will accept several optional command-line arguments.


Valid XHTML 1.0 Strict Valid CSS!