Multiple viewers of same server

Quentin Stafford-Fraser quentin "at" orl.co.uk
Wed, 29 Apr 1998 23:47:34 +0000


Marty,

> while(1) {
>  read(vnc machine)
>  for all connections
>    write to each connection
>  if(accept on vnc socket)
>  add another connection
> }


The problem here is the 'write to each connection' bit.  The connections may
all be very different speeds, as may be the viewers.  So this will be
limited by the speed of the slowest connection.  Normally data is only sent
to a viewer when it requests a new update, which prevents the server trying
to send data faster than it can be transmitted and consumed.

A better model for a proxy would be a main loop:

while (1) {
  read updates from server
  update local copy of screen
  add dimensions of updated region to the region held for each client
  for each client waiting for an update {
     encode and send the appropriate region of the local copy
     clear this client's region
  }
  request update from server when any client requests one
}

This is, essentially, what the X server does with multiple clients, and the
Windows server could do something similar, though, as Wez has mentioned, the
way it finds out about udpates is not quite so convenient for this model.

Quentin