Which software should I use, if I want to set up a linux VNC terminal server that works in this way:
The VNC server should be able to accept up to X simultanous connections on the same port 5900. The VNC server should use 640x480 on 8 or 16bit color.
When the VNC server receives the connection, it should start a new "session" for a user, and auto-launch a specific linux application for that user. If the application is killed, crashes, or is exited in any way, user should be disconnected (kicked) from server. If the user disconnect, the application should be killed in a "graceful way", that allows the application to cleanup.
(There should be no way to "pick up" a old session)
Any ideas?
You'd better go with NX. It's just like vnc but optimized, so it's much faster and more fluent on your screen. It's also easier to prepare profiles for your users.
you can set NX so he doesn't allow users to reconnect to an already opened sessions with:
DISABLE_PERSISTENT_SESSION
in the /etc/nxserver/node.conf file.
You can also set the command you want to be started at login in the NX client configuration. You can probably do it in the server configuration but I've never digged that far. Anyway I strongly suggest that you have a look at NX. It's available in centos extra repository and in other major linux distributions. It's based on the work of a commercial product which is partially open sourced. www.nomachine.com
Short answer is that you cannot do this with VNC. Each TCP port will be bound to a unique session. As far as I am aware you will have the same conundrum with Xpra, VNC, NX, etc. (going via a server, like freenx, and connecting via ssh is a workaround but not an ideal one!) You may be able to workaround this by writing a simple load-balancer type of application, but this will still require one port per client.
As for the rest of your question: the dimensions are specified with -screen. For just starting Xvnc with these options, something like this should work:
The Xvnc session and application startup: I would place all this in a script and start it from xinet.d
The tricky part is to prevent users from re-connecting to an existing session. This is a unusual requirement since that is one fundamental feature of VNC. You may be able to get away with parsing the output of the Xvnc process and killing it (with the app) when you see a disconnection event. For killing the Xvnc when the app terminates, just wait for the appication to terminate in your script and kill Xvnc if it is still running at that point.