2

I'm building a system with some remote desktop capabilities. The client is considered every computer which is sharing its desktop, the server is considered a central server with a database which receives the images of all the multiple desktops. On the client side, I would like to build two projects: A windows service application and a VCL forms application. Each client app would presumably be running under a different user account on the computer, so there might be multiple client apps running at once, and they all send their image into this client service, which relays them to the central server.

The service will be responsible for connecting to the server, sending the image, and receiving mouse/keyboard events. The application, which is running in the background, will connect to this service some how and transmit the screenshots into the service. The goal is that one service is running while multiple "clients" are able to connect to it and send their desktop image. This service will be connected to the "central server" which receives all these different screenshots from different "clients". The images will then be either saved and logged or re-directed to any "dashboard" which might be viewing that "client".

The question is through what method should I use to connect the client applications to the client service to send images? They will be running on the same computer. I will need both the abilities to send simple command packets as well as stream a chunk of an image. I was about to use the Indy components (TIdTCPServer etc.) but I'm sure there must be an easier and cleaner way to do it. I'm using the Indy components elsewhere in the projects too.

Here's a diagram of the overall system I'm aiming for - I'm just worried about the parts on the far right and far left - where the apps connect to the service within the same computer. As you can see, since there are many layers, I need to make sure whatever method(s) I use are powerful enough to accommodate for streaming massive amounts of image data.

System Structure

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 1
    possible duplicate of [Delphi 2009: How to communicate between Windows service & desktop application under Vista?](http://stackoverflow.com/questions/1260181/delphi-2009-how-to-communicate-between-windows-service-desktop-application-un) – Ken White Feb 15 '12 at 02:39
  • @KenWhite I disagree on the duplicate because my question is about streaming large images and the other questions is explicitly referring to "small strings" although the solution(s) may be similar, the goal is far different. – Jerry Dodge Feb 15 '12 at 02:50
  • Did you bother to read any of the answers to that question? There were several different options offered regarding `interprocess communication` (which is a great [search](http://stackoverflow.com/search?q=interprocess+communication+[delphi]) topic for this site, BTW, in conjunction with the `[delphi]` tag). – Ken White Feb 15 '12 at 03:02
  • Yes I did and indeed there are good answers there, but in the future people will be seeking keywords in the questions here, not in the answers. – Jerry Dodge Feb 15 '12 at 03:06
  • 1
    Jerry, the links I posted provide both the search topics **and** the answer to your question. – Ken White Feb 15 '12 at 03:09
  • 1
    How are you going to pick up mouse and keyboard events in a session 0 service? That's something for the desktop app to do. – David Heffernan Feb 15 '12 at 08:52
  • @DavidHeffernan That's exactly my goal, each user session (1 PC may have many) will be running its own app in the background. Each of those apps will connect to this service running on the same computer and transmit their images. That service connects to the central server and acts as a relay between the server and the client apps. These multiple apps will be taking the screenshots as needed. – Jerry Dodge Feb 15 '12 at 09:19
  • Oh I'm confused. This is remote admin rather than remote desktop I think. – David Heffernan Feb 15 '12 at 09:29
  • Yes, it's actually both admin and surveillance. – Jerry Dodge Feb 15 '12 at 10:30
  • 1
    If you keep calling it remote desktop then you will keep having to explain that the server and client are switched. So call it remote assistance/admin/surveillance. – David Heffernan Feb 15 '12 at 12:00

2 Answers2

1

Communicates among processes, you can use Pipe/Mailslots/Socket, I also think while sending a stream file Shared Memory maybe the most efficient way

horsley
  • 480
  • 4
  • 10
  • So with Shared Memory, are you suggesting to attach the processes together or something? I'm not sure what you mean... – Jerry Dodge Feb 15 '12 at 02:40
  • 1.Use Windows API CreateFileMapping to create a file-mapping kernel object 2. Use OpenFileMapping and then MapViewOfFile() to get Shared Memory 's pointer – horsley Feb 15 '12 at 02:42
  • @horsley is referring to `Memory Mapped Files`. A search on that phrase here (`memory mapped files delphi`) or on Google should provide enough info. It's only one of a half-dozen possibilities, depending on the amount of data you want to transfer and the responsiveness you need (memory mapped files involve disk I/O, which is obviously slower). – Ken White Feb 15 '12 at 02:49
1

I've done this a few times now, in a number of different configurations. The key to making it easy for me was using the RemObjects SDK which took care of the communications part. With a thread that controls its state, I can have a connection to a server or service that is reliable, and can transfer anything from a status byte through to transferring many megabytes of data (it is recommended that you use small chunks for large data so that you have more fine grained control over errors and flow). I now have a set of high reliability templates that I can deploy to make a new variation quite easily, and it can be updated with new function calls without much hassle (first thing I do is negotiate versions between the client and server so they know what they can support). Because it all works at a high level, my code is just making "function calls" and never worrying about what the format on the wire is. Likewise I can switch from their binary format to standard SOAP or other without changing the core logic. Finally, the connections can be local, to the same machine (I use this for end user apps talking to a background service) or to a machine on the LAN or internet. All in the same code.

mj2008
  • 6,647
  • 2
  • 38
  • 56
  • Yes, I will be sending large screenshots, but I will also be breaking them into chunks. My app compares small portions of the screen to the last taken image and only sends along pieces which have changed. – Jerry Dodge Feb 15 '12 at 10:33