John's VNC Read-Only Hack

First, thanks to the VNC folks for cranking out such a useful and cool tool and releasing it under the GPL.

This is a simple change I made to allow read-only RFB connections to the VNC Xserver (Xvnc). This was done to make VNC a bit more useful in a teaching environment but probably its useful in other situations. You can find VNC here.

The changes were made to version 3.3.3r1 of the Unix source. All of the changes are contained in the directory Xvnc/programs/Xserver/hw/vnc. The changes below work with 3.3.3r1.

The following was pulled from my changes to the README included with the source:

I bashed on the code here to provide read-only connections in addition
to the usual RFB port.  The reason is to provide an easy way for students
in a classroom environment to observe an instructor's screen without
having to look over the instructor's shoulder or look away from the
screen at a projector display.

I created the read-only RFB port because:

- It was easy to do because VNC already allowed shared connections.
- Its naive to think that students won't modify things given a shared
  write connection.
- The read-only RFB port is unauthenticated making it easier to use
  for the instructor (who doesn't have to give out the password) and
  the student (who doesn't have to fumble with typing a password).

The modifications include:

- A message is included in the ClientInitMsg to indicate to the
  user that others can view the display.  The vncviewer on Unix-like
  machines displays this message in the title bar.

- The feature is off by default.  You can enable it with:

  -readonlyport port#

- The message sent in the ClientInitMsg can be changed with:

  -readonlymsg message-string

- The fixed length buffer for the message was removed and the code
  written to use a dynamically allocated buffer to avoid Trouble.

- Turning on the read-only port automatically enables AlwaysShared
  in Xvnc.

I realize that using read-only RFB connections doesn't scale at all.
However, given el-cheapo 100Mbps network hardware and el-cheapo fast PCs
it was a simple solution for our environment.  On SGI O2s (slow
integer performance) we had decent results displaying things like
Mathematica, 2d java applications, and the like in a small environment
(5-7).  With recent dual-CPU PC things I suspect that it'll work just fine.