diff --git a/README b/README index 46ec6a0..9b7c5ff 100644 --- a/README +++ b/README @@ -5,8 +5,9 @@ What is it? ----------- VNC is set of programs using the RFB (Remote Frame Buffer) protocol. They -are designed to "export" a frame buffer via net. It is already in wide use -for administration, but it is not that easy to make a server yourself. +are designed to "export" a frame buffer via net (if you don't know VNC, I +suggest you read "Basics" below). It is already in wide use for +administration, but it is not that easy to program a server yourself. This has been changed by LibVNCServer. @@ -175,7 +176,77 @@ History LibVNCServer is based on Tridia VNC and OSXvnc, which in turn are based on the original code from ORL/AT&T. -VNC fascinated me from t +When I began hacking with computers, my first interest was speed. So, when I +got around assembler, I programmed the floppy to do much of the work, because +it's clock rate was higher than that of my C64. This was my first experience +with client/server techniques. + +When I came around Xwindows (much later), I was at once intrigued by the +elegance of such connectedness between the different computers. I used it +a lot - not the least priority lay on games. However, when I tried it over +modem from home, it was no longer that much fun. + +When I started working with ASP (Application Service Provider) programs, I +tumbled across Tarantella and Citrix. Being a security fanatic, the idea of +running a server on windows didn't appeal to me, so Citrix went down the +basket. However, Tarantella has it's own problems (security as well as the +high price). But at the same time somebody told me about this "great little +administrator's tool" named VNC. Being used to windows programs' sizes, the +surprise was reciprocal inverse to the size of VNC! + +At the same time, the program "rdesktop" (a native Linux client for the +Terminal Services of Windows servers) came to my attention. There where even +works under way to make a protocol converter "rdp2vnc" out of this. However, +my primary goal was a slow connection and rdp2vnc could only speak RRE +encoding, which is not that funny with just 5kB/s. Tim Edmonds, the original +author of rdp2vnc, suggested that I adapt it to Hextile Encoding, which is +better. I first tried that, but had no success at all (crunchy pictures). + +Also, I liked the idea of an HTTP server included and possibly other +encodings like the Tight Encodings from Const Kaplinsky. So I started looking +for libraries implementing a VNC server where I could steal what I can't make. +I found some programs based on the demo server from AT&T, which was also the +basis for rdp2vnc (can only speak Raw and RRE encoding). There were some +rumors that GGI has a VNC backend, but I didn't find any code, so probably +there wasn't a working version anyway. + +All of a sudden, everything changed: I read on freshmeat that "OSXvnc" was +released. I looked at the code and it was not much of a problem to work out +a simple server - using every functionality there is in Xvnc. It became clear +to me that I *had* to build a library out of it, so everybody can use it. +Every change, every new feature can propagate to every user of it. + +It also makes everything easier: + You don't care about the cursor, once set (or use the standard cursor). +You don't care about those sockets. You don't care about encodings. +You just change your frame buffer and inform the library about it. Every once +in a while you call rfbProcessEvents and that's it. + +Basics +------ + +VNC (Virtual network computing) works like this: You set up a server and can +connect to it via vncviewers. The communication uses a protocol named RFB +(Remote Frame Buffer). If the server supports HTTP, you can also connect +using a java enabled browser. In this case, the server sends back a +vncviewer applet with the correct settings. + +There exist several encodings for VNC, which are used to compress the regions +which have changed before they are sent to the client. A client need not be +able to understand every encoding, but at least Raw encoding. Which encoding +it understands is negotiated by the RFB protocol. + +The following encodings are known to me: +Raw, RRE, CoRRE, Hextile, CopyRect from the original AT&T code and +Tight, ZLib, LastRect, XCursor, RichCursor from Const Kaplinsky et al. + +If you are using a modem, you want to try the "new" encodings. Especially +with my 56k modem I like ZLib or Tight with Quality 0. In my tests, it even +beats Tarantella. + +There is the possibility to set a password, which is also negotiated by the +RFB protocol, but IT IS NOT SECURE. Anybody sniffing your net can get the +password. You really should tunnel through SSH. License ------- diff --git a/TODO b/TODO index 38aa6b6..68dd3b0 100644 --- a/TODO +++ b/TODO @@ -3,18 +3,20 @@ immediate: fix bug in http (java) client with big endian server: byte swapping is broken cursor "smears" sometimes when not using cursor encoding +really support pthreads. in the works: ------------- adapt rdp2vnc (rdesktop) optionally dont draw rich cursors as xcursors -use sraRegion from rdp2vnc instead of miregion, because it is much smaller +use sraRegion from Wez instead of miregion, because it is much smaller later: ------ udp +autoconf rfbCloseClient, rfbConnect, ConnectToTcpAddr CORBA translate.c: warning about non 8-bit colourmaps diff --git a/example.c b/example.c index 0da149b..bab1075 100644 --- a/example.c +++ b/example.c @@ -241,42 +241,42 @@ void MakeRichCursor(rfbScreenInfoPtr rfbScreen) " xxxxxx " " xxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxx " + " xxxxx xxxxxxxx xxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " + " xxxxx xxxxxxxxxxx xxxxxxx " + " xxxx xxxxxxxxx xxxxxx " + " xxxxx xxxxxxxxxxx xxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " + " xxxxxxxxxxxx xxxxxxxxxxxxxxx " + " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxxxxxxx " + " xxxxxxxxxxx xxxxxxxxxxxxxx " + " xxxxxxxxxx xxxxxxxxxxxx " + " xxxxxxxxx xxxxxxxxx " + " xxxxxxxxxx xxxxxxxxx " " xxxxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxxx " - " xxxxxxxxxxxxxx " - " xxxxxxxxxxxx " - " xxxxxxxxxxxx " - " xx xxxxxxxxxxx " - " xxx xxxxxxxxxxx " - " xxxx xxxxxxxxxxx " - " xxxxxx xxxxxxxxxxxxx " + " xxxxxxxxxxxxxxxxxxx " + " xxxxxxxxxxxxxxxxxxx " + " xxxxxxxxxxxxxxxxx " + " xxxxxxxxxxxxxxx " + " xxxx xxxxxxxxxxxxx " + " xx x xxxxxxxxxxx " + " xxx xxxxxxxxxxx " + " xxxx xxxxxxxxxxx " + " xxxxxx xxxxxxxxxxxx " " xxxxxxxxxxxxxxxxxxxxxx " " xxxxxxxxxxxxxxxx " " "; - c=rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,0); - c->xhot = 2; c->yhot = 10; + c=rfbScreen->cursor = rfbMakeXCursor(w,h,bitmap,bitmap); + c->xhot = 16; c->yhot = 24; c->richSource = malloc(w*h*bpp); for(j=0;jrichSource[j*w*bpp+i*bpp+0]=0; //i*0xff/w; - c->richSource[j*w*bpp+i*bpp+1]=0; + c->richSource[j*w*bpp+i*bpp+0]=i*0xff/w; + c->richSource[j*w*bpp+i*bpp+1]=(i+j)*0xff/(w+h); c->richSource[j*w*bpp+i*bpp+2]=j*0xff/h; c->richSource[j*w*bpp+i*bpp+3]=0; } diff --git a/main.c b/main.c index 18b143b..ee97164 100644 --- a/main.c +++ b/main.c @@ -306,29 +306,17 @@ void defaultSetXCutText(char* text, int len, rfbClientPtr cl) static rfbCursor myCursor = { - //width: 8, height: 7, xhot: 3, yhot: 3, - width: 8, height: 7, xhot: 0, yhot: 0, - //source: "\000\102\044\030\044\102\000", - //mask: "\347\347\176\074\176\347\347", - source: "\000\074\176\146\176\074\000", - mask: "\176\377\377\377\377\377\176", + width: 8, height: 7, xhot: 3, yhot: 3, + source: "\000\102\044\030\044\102\000", + mask: "\347\347\176\074\176\347\347", + /* + width: 8, height: 7, xhot: 0, yhot: 0, + source: "\000\074\176\146\176\074\000", + mask: "\176\377\377\377\377\377\176", + */ foreRed: 0, foreGreen: 0, foreBlue: 0, backRed: 0xffff, backGreen: 0xffff, backBlue: 0xffff, - #define D "\000\000\000\000" - #define R "\377\000\000\000" - #define G "\000\377\000\000" - #define B "\000\000\377\000" - #define S "\377\377\000\000" - #define H "\000\377\377\000" - #define C "\377\000\377\000" richSource: 0 - /*D D D D D D D D - D D R R R R D D - D S S S S S S D - D G G D D G G D - D H H H H H H D - D D B B B B D D - D D D D D D D D*/ }; rfbCursorPtr defaultGetCursorPtr(rfbClientPtr cl) @@ -435,6 +423,12 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv, return(rfbScreen); } +void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen) +{ + /* TODO */ + free(rfbScreen); +} + void rfbInitServer(rfbScreenInfoPtr rfbScreen) { rfbInitSockets(rfbScreen); diff --git a/rfb.h b/rfb.h index 225e0b9..c7eaae8 100644 --- a/rfb.h +++ b/rfb.h @@ -612,7 +612,8 @@ extern void rfbScreenCleanup(rfbScreenInfoPtr screenInfo); /* call one of these two functions to service the vnc clients. usec are the microseconds the select on the fds waits. - if you are using the event loop, set this to some value > 0. */ + if you are using the event loop, set this to some value > 0, so the + server doesn't get a high load just by listening. */ extern void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, Bool runInBackground); extern void rfbProcessEvents(rfbScreenInfoPtr screenInfo,long usec);