server memory vs desktop memory

Writing Plugins for rdesktop
Written by:
Sergey Yakimenko,
Senior Software developer team of drivers,
Apriori http://www.apriorit.com Inc.
Summary
About this article when itâ € ™ s reading of dollars
Rdesktop. RDP
Writing Plugins for rdesktop: utilization review of OOP
Principles to Code
The client: plugin
Some of the clients: rdesktop
On the server side
The final
About this article: When itâ € ™ s reading of dollars
This article was written primarily for Linux developers. The document provides a method Writing outside the process open source software plug-ins â € "ie, the plugins will work as part of the program but will run in another process, so that your code remains closed in May.
In general there € ™ s not necessary to use the method described in the text. Rdesktop is a free software and you can always change sources any way you need. However, this means you must make the code open yes, because that is what the GPL requires. ™ € If you donâ t want this yet, read on and think youâ € ™ learn to avoid the requirement of LPG and write a plugin that the code will be closed and work in the rdesktop code.
You may also read this to know something interesting about:
- RDP
- Rdesktop â € "an open source RDP client
- process simple means of communication between * nix systems.
Let's begin.
Rdesktop. The RDP protocol.
This is for those who nâ € ™ t know what it is. Remote Desktop Protocol (RDP) is a proprietary protocol developed by Microsoft that seeks to provide a user with a graphical interface to another computer. This is very useful â € "you can work on another computer at his desk, almost no differences in appearance and performance (of course, if you have a good network connection € "high speed with little latency, and thus on and so forth). There € ™ re RDP clients for almost all operating systems â € "Windows, Linux, Mac OS, and they use all RDP to connect to an RDP server â € "a remote host to which you want to work. In 2008, he opened Microsoft's RDP specification, are now available on your site: http://msdn.microsoft.com/en-us/library/cc216513 (PROT.10). aspx.
Rdesktop is an open client code for Windows Terminal Services. Currently works on most UNIX platforms with X Window System. It supports most basic features of RDP protocol and protocol extensions, including audio redirection, clipboard, the local file system and device redirection. Rdesktop is released under the GNU Public License (GPL).
Like many other programs * nix, Rdesktop is an application command line. It has lots of different input parameters of a Remote set up an identification of user connection € "address of the server, desktop size, color depth, also the description of the premises to be redirected to the remote computer â € "behaves, printers, audio discs.
Analysis of its command line and the beginning of a session to a remote host rdesktop enters an infinite loop where it reads the incoming data to About the data sent by the server and sends data to the server in response. The server connection is through what are called virtual channels. Microsoft has a floor:
"Virtual channels are software extensions that can be used to add improvements a functional application services Remote Desktop. Examples of functional enhancements in May include support for specific types of equipment computer, audio, or other additions to the basic functionality offered by the services the Remote Desktop Protocol Remote Desktop (RDP - http://msdn.microsoft.com/en-us/library/aa383015 (VS.85). Aspx). The RDP protocol allows for multiplexing of managing multiple virtual channels.
An application of virtual channel consists of two parts: a component side client and a server component. The server component is an executable program running in the Remote Desktop session host (Host session GDR) from server. The client-side component is a DLL that is loaded into memory on the client computer when the connection client software Remote Desktop (RDC) is executed.
Virtual Channels can add functional enhancements to connect remote desktop (RDC), Protocol Independent PDR. With the support of the virtual channel, new features can be added without having to update the client software or server, or RDP.
Thus, virtual channels are just a way of knowing how two extremes â € "a program client and server, for example â €" can connect to itself, regardless protocol layer below. Remote Desktop Services is RDP, but can be quite different in the case that provide similar capabilities.
Write plugins for rdesktop: in a case of Object Oriented Programming
As mentioned above, if you can modify the sources for rdesktop add or modify the functionality required. There is another way, if â € "if you want to open all the code changes the world, you can create a standalone program that works as an add rdesktop.
There is a patch that makes the capacity of a virtual channel which is visible in rdesktop, € third a "make it possible to create and work with other controllers of virtual channels that run as separate programs. The patch is mainly Written by Simon Guerrero. You can get the fix: Sourceforge.net (http://sourceforge.net/tracker/index.php?func=detail&aid=1472969&group_id=24366&atid=381349 - A detailed description on the page is outdated - refers to the old version of the exam, and does not reflect its current state. It is simply unnecessary). After being updated with this patch, rdesktop œredirection receives an additional â € (r) â € parameter - '-R addin'. The complete format of the parameter is:
r-Addin: <channelname>: </ path / to / executable [: arg1 [: arg2 :]...]
where
<channelname> - The name of the desired virtual station, "/ path / to / executable> - path to the driver CV; [: arg1 [: arg2 :]...] - optional parameters passed to the controller rdesktop.
A few words about the driver of venture capital. When rdesktop creates the process controller and the corresponding virtual channel, connects the output of capital risk to the process standard input (stdin) and vice versa â € "which is the standard output (stdout) connects to the SCR. Optional Parameters are passed to the process parameters as command line. Therefore, the only thing the driver needs to do is read the incoming data venture capital from standard input and write data on venture capital to exit standard. Very simple and clear pattern, described below in more detail.
Principles Code
Well, that's how it Works. The code is not as elegant but it works and does what is necessary. Then take a look:
Client part: plugin
Where plugin starts, knows he has been directed by rdesktop and its stdin and stdout are connected to the input channel virtual output. This plugin works only on an infinite loop that reads data from the CV and send data in response to need. It also establishes a handler SIGUSR1 signal, so that rdesktop can finish the job properly plugin. When rdesktop disconnect from the remote computer, you will be sent SIGUSR1 to all plugins, and plugins Receive SIGUSR1 must cease operations:
static int g_end_flag = 0, / / rdesktop sends a closing event by sending void sigusr1_handler SIGUSR1 (int signum) (g_end_flag = 1;) / / are released from rdesktop with the following parameters: / / 1) finished our reading and writing in the piping that connects us to rdesktop / / Â Â Â passed as stdin and stdout / / 2) all parameters are passed by argv [] int main (int argc, char ** argv) (char * data = NULL, unsigned long datalen = 0; int pipe_to_read = -1; pipe_to_write int = -1; int i; A / / Set the handler SIGUSR1 SA struct sigaction; = sigusr1_handler sa.sa_handler; (sigaction SIGUSR1, & sa, NULL); Â Â pipe_to_write pipe_to_read = dup (STDOUT_FILENO) = dup (STDIN_FILENO) Â Â Â while (! G_end_flag) (ssize_t bytes_read = read (pipe_to_read and datalen, sizeof (unsigned long)) if (g_end_flag) break if (bytes_read <= 0) (perror ( "pipe read"); break;) Â Â Â Â Â Â Â data = malloc (datalen) Â Â Â Â Â Â ssize_t all_read = 0; do (bytes_read = read (pipe_to_read, all_read + data, datalen - all_read) all_read + = bytes_read;) while (bytes_read> 0 & & all_read <datalen & &! G_end_flag) Â Â Â Â Â / / Just send back, if the received data (bytes_read> 0) (write (pipe_to_write, and datalen, sizeof (unsigned long)) write (pipe_to_write, data, datalen)) Â Â Â Â Â free (data) data = NULL;) final:
Â
   if (data! = NULL) free (data); near (pipe_to_read) close (pipe_to_write)    return 0;)
A part of the clientele: rdesktop
When rdesktop is an "-r addin 'parameter,
case 'R': if (str_startswith (optarg, "Addin")) (initialize, and added to the list of extras: init_external_addin (addin_name, addin_path, p and addin_data [addin_count]) if (addin_data [addin_count]. pid = 0) (addin_count + +;)
In the init function prepares Completion Completion rdesktop parameters, the process creates and connects driving:
init_external_addin void (char * addin_name, addin_path char *, char * args, ADDIN_DATA * addin_data) (char * p; current_arg char *, char * argv [256]; argv_buffer char [256] [256]; int i; readpipe int [2], [writepipe 2]; pid_t child; / addin * Initialize structure * / memset (addin_data, 0, sizeof (ADDIN_DATA)) / * Go to the list of arguments, adding each argv * / argv [0] = addin_path i = 1, p = args = while current_arg (current_arg! = 0 & & current_arg [0]! = ' 0') (p = next_arg (p, ":");; if (p! = 0 & & * p! = " 0 ") * (p - 1) =" 0 "; strcpy (argv_buffer [i], current_arg), argv [i] = argv_buffer [i], i + +; current_arg = p;) argv [i] = NULL, / * Create a pipe * / if (pipe (readpipe) <0 | | pipe (writepipe) <0) (perror ( "pipe Addin"); return;) / * Fork the process * / if ((child = fork ()) <0) (perror ( "fork Addin"); return;) / * son * / if (child == 0) (/ * Set relevant pipe stdout and stdin of the child end * / dup2 (writepipe [0], 0), dup2 (readpipe [1], 1) / * close all SDS, and which are not necessary now * / close (readpipe [0]) close (readpipe [1]); near (writepipe [0]); near (writepipe [1]); execvp ((char *) argv [0] (char **) argv); perror ( "Error executing child"); _exit (128)) else (strcpy (addin_data-> name, addin_name) / * End Child close FD "s * / close (readpipe [1]); close (writepipe [0]); addin_data-> pipe_read readpipe = [0]; addin_data-> pipe_write = writepipe [1] -> addin_data vChannel channel_register = (addin_name, CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP, addin_callback) if (! Addin_data-> vChannel) (printf ( "Channel registration failed") return;) else addin_data-> pid = boy;))
The addin_callback () is called each Once the data are received additional VC:
/ * Callback for the generic provision of data to third parties ons * / void addin_callback (Stream s, char * name) (pid_t pid, int pipe_read; pipe_write int, uint32 block; / * s-> p is the beginning and s-> end is ordered, plus 1 * / S = block-> end - S-> p / * to complement the name of the CV * / lookup_addin (name, & pid, & pipe_read and pipe_write) if (pid) perror ( "Can not locate Addin ") else (/ * Add the block with the block size so that the plug can identify blocks * / Write (pipe_write and block size, sizeof (UInt32)), write (pipe_write, s-> p, block);))
The data are read by adding the complete pipe end cap to the series of file
/ * Add the pipe to complete the set of file descriptors * / Addin_add_fds (int * n, fd_set * rfds) addin_data ADDIN_DATA (extern []; addin_count extern int int i; addin_count for (i = 0, I <i + +) (FD_SET (addin_data [i]. Pipe_read, rfds) * n = MAX (* n, addin_data [i]. Pipe_read);))
select () "Ing with the game:
select (n, & rfds, and wfds, NULL, & tv);
The descriptors are checked in an infinite loop.
/ * Check the plug in the piping of data to write * / void Addin_check_fds (fd_set * rfds) addin_data ADDIN_DATA (extern []; Addin_count extern int i int, char buffer [1024] ssize_t bytes_read; Stream s; addin_count for (i = 0, i + <+ i) (if (FD_ISSET (addin_data [i]. Pipe_read, rfds)) (bytes_read = read (addin_data [i]. pipe_read, 1024), buffer, if (bytes_read> 0) (/ * write em record * / s = channel_init (addin_data [i]. Vchannels, bytes_read); memcpy (s-> p, buffer, bytes_read) s-> p + = bytes_read; s-> end = s-> p; channel_send (s addin_data [i]. );)))) vChannel
On the server side
On the server side to be open a virtual channel and wait for the request. You will find a example of patch Page: example - http://sourceforge.net/tracker/download.php?group_id=24366&atid=381349&file_id=313601&aid=1472969.
The final
Well, that's all. We hope that this information was useful. You can use this method, not only for rdesktop, but other programs as well as â € "all the time to write a closed source add another program whose code can be changed.
So, good luck!
About the Author
Apriorit is the providers of the professional consulting and software development services in the knowledge-intensive scopes.
One of the key values of Apriorit's specialists is knowledge generation and sharing of experience.
Learn more about Apriorit and its experience at Apriorit Official site
memory server Vs Desktop?
What is the difference between the memory of a server against the memory of my office. My Office Mushkin has 1 GB of RAM 2700. Will work PC2700 memory on the server in it?
If server memory is not ECC. Most computers use ECC not, unless the material used as a server computer (which will be built).
How to expand your virtual memory