Use netcat [dict.org](<http://dict.org>) 2628 to connect to dict.org via the terminal.

What command would you use to discover the definition of the word "pemican"?

define wm pemican OR define * pemican # find definition of "pemican"

How many different dictionaries contain a definition of the word "protocol"?

match * exact protocol

What command would you use to find all the words that "sound like" the word "orange"?

match * soundex orange

Connecting to a web server

Try the following command to connect to a web-server on the standard port 80.

netcat example.com 80

To close a netcat session, simply use Ctrl-D (to close cleanly) or Ctrl-C (to close abruptly).

You will probably note that unlike the previous connections, this time there is no immediate response.  Unlike the previous two protocols, web servers silently wait for more information from the client before they respond in any way.  If you type some input, like the word "hello", the server will then respond (with an error message, because it isn't expecting that response).  Try it.

There is one additional complication about clients and servers.  How can a server recognize the end of a line? One simple way, but not the only way, is for the client and server to have a special end-of-line character (or in this case end-of-message) which is sent whenever you hit return and is used by the server on the other side to terminate the message.   Unfortunately the Unix world and Windows world never quite agreed on how to terminate messages. In Unix "\n" is used while Windows uses two characters "\r\n".  Most protocols expect "\r\n" but some servers will allow you get away with just "\n".   You are best to always send the "\r\n" (also known as CRLF).

On the undergraduate machines netcat does not send a "\r" carriage return by default.  Use the "-C" (capital-C) flag to tell nc to send a carriage return along with each newline ("\n").     You will also need to pay attention to the capitalization of the information you send to the server.

Connect to the web server again, and then provide the following two lines of input, followed by a blank line:

GET / HTTP/1.0
Host: example.org