The SocketViewer program can be used to communicate with any server that uses a textual protocol such as HTTP. It records all text and relevant program messages for a connection with color-coding indicating whether text originated from the user, the server, or the SocketViewer program.

To get the SocketViewer program download this zipfile. After unzipping it, enter the unzipped directory and click on the SocketViewer.jar file. The "Help" tab in the program's user interface explains how to operate the program.

This socket viewer allows you to interact with a server in order to better understand how protocols work. The easiest protocol example is HTTP (HyperText Transfer Protocol), the transfer protocol used between web browsers and web servers.

Suppose you want to "speak" HTTP with the web server to fetch the web page whose URL is You would first need to connect to the server. This is done by entering "" into the "Host Name" field at the top of the "Viewer" panel. Then enter the port number 80 into the "Port" field. This is the port used by most web servers. Then click on the "Open" button. You should see the message the following message.

  Connected to

If so, you have a connection established and you are ready to "speak" HTTP to the web server. The red to the left of the message indicates that the text was written by the SocketViewer program itself.

After a connection is established with a web server, the server expects to receive requests of various types. The most common type of request is a "GET" request. It starts with the following line.

  GET path-to-web-page HTTP/1.1

The path-to-web-page starts with a forward slash ("/") character and is the path to the desired web page on that server. For example, to access the page, you would enter the following line.

  GET /~gshute/net/nettest.html HTTP/1.1

This should be followed by a carriage return and a line feed. This is sent when you hit the "Enter" key on the keyboard. As soon as you have done this the color to the left of the line turns blue. This indicates that the line was entered by you and that it has been sent to the server.

After sending the "GET" line, you need to send request header lines that specify parameters for the request. These lines have the following form.

  name: value

There is one mandatory header line that needs to be sent first: the "Host" parameter. Its value is usually the host name of the server that you are connected to. For this example, you would enter the following.


Again, this is followed by hitting the "Enter" key. Also try entering a header line for a parameter named "Connection" with the value "close".

Now you have sent the command and its parameters. To tell the server that there are no more parameters, you just send a blank line by hitting the "Return" key. You should get a response from the server, indicated by green color to its left. The response consists of the following in order:

The status line should be the following.

  HTTP/1.1 200 OK

The response header lines have the same format as request header lines. They convey information about the response to a browser. The blank line signals the end of the header lines, as it did in the request. After the response, you should also see a "Connection terminated." message in the viewer.

A web browser will normally want to keep the connection alive in case another web page will be requested from the same server. It does this by not sending the "Connection: close" header line. After it receives the full response as indicated by the "Content-Length" response header line, it sends a carriage return and a line feed to indicate that it is still connected. Then it can later send more "GET" requests. If the browser does not send the carriage return and line feed within a few seconds the server will automatically terminate the connection.

The SocketViewer Color Code

The source of text and editability of is indicated by the color in the vertical bar to its left as shown below.

Red indicates a message from SocketViewer. A SocketViewer message generally reflects status of the connection. Its text cannot be edited.

Blue indicates text that has already been sent to the server. Once sent to the server the text cannot be edited.

Green indicates a response from the server. Its text cannot be edited.

White indicates text entered by the user but not yet sent to the server. The text can be edited by the user like normal text in a graphical user interface until it is sent to the server. It is sent to the server when the "Enter" key is pressed.

Unlike what is shown here, only one line at a time has a white bar to the left. The bar to the left of earlier lines would have turned blue when "Enter" was pressed.