This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lyqyd's profile picture

vncd - an nsh-compatible VNC server

Started by Lyqyd, 23 February 2014 - 06:48 PM
Lyqyd #1
Posted 23 February 2014 - 07:48 PM
vncd is a companion to nsh that allows you to control a computer and see what is currently on its screen. It differs from nsh in that nsh spawns a new isolated shell session for each computer that connects. This alternate server program shows exactly what is on the screen to each client that connects, like a real VNC server. This allows you to more easily check on the progress of a running program from any computer in range.

The best way to get vncd is via packman, with the command packman install vncd, as this will fetch vncd and its dependencies automatically. You could also grab it from pastebin:

vncd: MC4RFZEK, or simply: pastebin get MC4RFZEK vncd
framebuffer (required!)I: Aaza6h5v, or simply: pastebin get Aaza6h5v framebuffer

Since vncd interrupts the startup process (no lines after vncd starts will be executed), it allows the option of specifying a program to run when it launches its shell coroutine, so that other programs may be run if necessary. Simply run it with the file name of the file to run when it is started and the shell coroutine it starts will execute that file.

To connect to the vnc server, simply use the nsh client as you normally would to connect to an nsh server, nsh <serverID>.
Alice #2
Posted 23 February 2014 - 10:13 PM
Looks cool, I was hoping to implement something like this into my operating system, but someone had to beat me to it… c:
Nice job though. Not able to test it right now but sounds cool.
Thib0704 #3
Posted 26 February 2014 - 05:46 PM
Thats a cool program!
LDShadowLord #4
Posted 01 March 2014 - 08:51 PM
Can I run this in secret on a targets computer? As long as they don't look at the startup file?
Lyqyd #5
Posted 02 March 2014 - 12:28 AM
Yes, the only noticeable evidence that vncd is running is that the wireless modem attached to the computer will be active, if you don't look in the startup file.
airminer #6
Posted 26 April 2014 - 11:09 PM
I think in the main loop this:

while true do
should be replaced with this:

while coroutine.status(co.thread) ~= "dead" do

The way it is now, the only way the program can be terminated is via reooting, or breaking the computer, and if the program launched by vncd terminates, the computer hangs.

The new code stops vncd when the first client disconnects, which is not ideal, but is better, than hanging idefinately.
Edited on 26 April 2014 - 09:18 PM
Lyqyd #7
Posted 27 April 2014 - 05:59 PM
Thanks for the suggestion! I'll take a look at the best way to make this change.
Lupus590 #8
Posted 13 April 2015 - 01:15 AM
Sorry if this is a necro.

While testing this out (a while ago now, so I may not be right), I noticed that the screen of the hosting computer (the one running vncd) is blank. Is there a way for the screen of the host to be the same of the connected clients? also, do all of the clients see the interactions of the other ones? (I forgot to test that)
Lyqyd #9
Posted 13 April 2015 - 05:35 AM
The computer running the server shouldn't have a blank screen. Thanks for the bug report, I'll look in to it!
Lupus590 #10
Posted 13 April 2015 - 12:43 PM
If you need it, the code I used is on my Hive GitHub Tell me if it was out of date (I 'pulled' it from your github, can't find which one it was)
while testing I did remove the lua extension from framebuffer


Edit: I'm testing again, not connected a client to it yet, works fine.

just connected the client, still works

ignore my bug report, I have no idea what quirk I am recalling

got a graphical glitch with nsh though http://www.computercraft.info/forums2/index.php?/topic/6472-nsh-now-with-previous-session-resume/page__st__40__gopid__213801#entry213801
Edited on 13 April 2015 - 11:11 AM
Lupus590 #11
Posted 17 April 2015 - 04:30 PM
I can't terminate the program running under VNCD, I'm holding ctrl-t with direct (person player to server) access to the server computer (or turtle in my case)

also, not sure if this is to do more with nsh, but could add a scroll bar or something so I can see on my pocket computer?
This is the problem
what is the label, what is the LABEL!!!!
Edited on 17 April 2015 - 03:13 PM
Lyqyd #12
Posted 17 April 2015 - 05:43 PM
Hah, yeah, this could use a dedicated client to allow scrolling around in the screen space for mismatched client screen dimensions. Ctrl-T is a tricky thing. The nsh client uses ctrl-t to terminate the local client instance, so perhaps this can also be solved using a special client for the vnc connections.

Thanks again for the reports, I'll try to take a whack at this over the weekend.
LDDestroier #13
Posted 17 April 2015 - 07:37 PM
It would be a lot more conveinient if you could automatically download your framebuffer API by doing nsh or vncd with an argument, like how FileNet works with its APIs.

Sorta like this…

nsh dlapi
vncd dlapi
…downloading the api if it doesn't exist.
You can also include the api inside of the program, non-externally…
Lupus590 #14
Posted 17 April 2015 - 07:52 PM
It would be a lot more conveinient if you could automatically download your framebuffer API by doing nsh or vncd with an argument, like how FileNet works with its APIs.

Sorta like this…

nsh dlapi
vncd dlapi
…downloading the api if it doesn't exist.
You can also include the api inside of the program, non-externally…

or have the program ask if you want to download it if it cant find it

or have it ask you to find it

Hah, yeah, this could use a dedicated client to allow scrolling around in the screen space for mismatched client screen dimensions. Ctrl-T is a tricky thing. The nsh client uses ctrl-t to terminate the local client instance, so perhaps this can also be solved using a special client for the vnc connections.

Thanks again for the reports, I'll try to take a whack at this over the weekend.

the ctrl-t was on the server, no client was needed to be connected
Lyqyd #15
Posted 17 April 2015 - 07:59 PM
It would be a lot more conveinient if you could automatically download your framebuffer API by doing nsh or vncd with an argument, like how FileNet works with its APIs.

Sorta like this…

nsh dlapi
vncd dlapi
…downloading the api if it doesn't exist.
You can also include the api inside of the program, non-externally…

Installing nsh via packman will automatically download framebuffer as well. I do need to add vncd to packman's system, which I will be sure to do tonight. I'm not really wanting to build fetching functionality into nsh/vncd, since they do work without framebuffer (or should, if they don't, it's a bug), and packman is the preferred/correct way to install scripts I've written. I will also update the first post to mention installation via packman being the preferred method.

I'll think about it a bit more, though.
Lyqyd #16
Posted 30 May 2015 - 08:45 PM
The way it is now, the only way the program can be terminated is via reooting, or breaking the computer, and if the program launched by vncd terminates, the computer hangs.

The new code stops vncd when the first client disconnects, which is not ideal, but is better, than hanging idefinately.

This has been resolved. Sorry this fell through the cracks for so long!

I've also fixed an issue with connection looping caused by vncd not publishing an nsh API stub so that nsh clients could check the state of connections prior to attempting to connect.
Lupus590 #17
Posted 09 December 2015 - 02:19 PM
bug report: vncd on an advanced computer, with and without connections

typing any character causes the following error to display on the host

bios:286: Redirect object is missing method getTextColor

I believe that the actual error is in framebuffer, but that's a guess
Lyqyd #18
Posted 09 December 2015 - 05:44 PM
Yes, looks like the version on pastebin is outdated. If you've installed via packman, a simple `packman fetch update` should solve the issue. I'll update the pastebin code tonight.

And I saw your suggestion a while back and have been kicking the idea around in my head, I just haven't really had the time/mindset to sit down and evaluate the feasibility of the idea. If it's going to get implemented, it may have to be something that's disabled by default.
Lupus590 #19
Posted 09 December 2015 - 06:12 PM
I'm planing on writing my own nsh/vncd program set which will have the feature, I'm hoping to make it nsh compliant.

Am i right in thinking that this is what I'll need to follow to make our programs compatible?
Lyqyd #20
Posted 09 December 2015 - 07:34 PM
Yes, though there is an additional "textTable" packet type (in which the buffer contents are sent whole) that vncd will only use, and that nsh will use when the framebuffer API is available. I should add that to the RFC post, thanks.
Mumbai #21
Posted 08 July 2016 - 05:28 PM
Would love to try this program, but…I seem to be having a problem

I downloaded the file via packman. NExt, on another computer, i installed NSH.

I ran vncd on the server. Then, I ran nsh (serverid) on the one wishing to connect.

It connected. Then I hit one key and it disconnected. Tried this multiple times.