Principle of remote control computers
Way
L C / S mode
The C / S mode is similar to PCAnywhere, requiring a server and a client, which is installed on different computations, and the Client computer controls the computer where Server is located. Generally used in the local area network, use TCP protocols, if you use a proxy server or a server or a server online, but its affected by the firewall is relatively large.
l web mode
It is a B / S mode, actually a variant of the C / S mode, but the client is a browser, so the Client does not need to install specific software, but the Server side needs to install software. When any calculation wants to access the server, you will get the specified connection to the specified web page. He needs at least a web server, and in order to ensure the security of the communication, it is best to communicate service services in order to ensure the security and cross-firewalls and local area networks.
2. Principle
The above two modes are similar, requiring a network communication server and client, but only two modes may be different (one is the development of Application, the other is a browser, actually on the browser Plug-in to complete communication), but it transmits data, the mechanism of acquiring control is the same.
Here is the SERVER and Client to explain.
l Server
The Server end needs to run a software based on TCP / IP (generally select TCP comparison), listen in a port (the famous port of the Client side). It is a multi-threaded program that gets a new thread to process the client when Listen to Client is requested.
Since it is a remote control program, Client's request is nothing more than viewing screen, passing file, operating server, etc. Let's explain one by one below:
View the screen: In fact, after the Client connection, Server needs to send its screen to the client, sending a processed picture (here is very important to the picture format and compression algorithm), but an important question is how The change of the screen is an important performance problem. If you keep sending information, it will be undoubtedly the most stupid. There are many ways to check the amount of change in the picture information. There is also a way to get refresh from the hardware graphics card (this method is like Microsoft / WebEx, but this method is very helpful for performance) . The resulting image needs to be adjusted according to the resolution of the Client.
Operation Server: When the client is operating on the on-screen, he can get its mouse event / keyboard event and coordinates on the image, send this information to the Server. Server will analyze the information, parse different system messages (WM_) according to different information, and then restore the system message via the mouse_event and key_event functions to obtain the client's operation.
Pass the file: Know the two processes above, pass the file is a little meaning, just a file copy process.
l Client
Client needs to know the server IP and port (if you are on the web, this information is obtained from the web server, and its port is usually used 80 port), then the Client sends a connection request if server is online, then it is connected.
After connecting, you first get the server screen, actually a picture file, then display it in the client side according to the resolution of the Client, and there are two cases in the future: 1. SERVER actively changed the information (only this situation only when the Server side is active), the client only needs to update the screen.
2. The client sends changes, this time does not need to change the screen, but will then have updated content from Server.
When the client is acting as a Server computer, you first get the location on the current picture, then convert to the coordinates on the Server, and record the mouse time and keyboard events, and send it to the Server side.
3. Implement
The above is the basic process, and mainly on the Window platform, using the socket can implement the communication section. Of course, the specific implementation code still has some workload.