Posted in
c#,
client,
desktop,
host,
Image,
PHP,
pickle,
project,
remote,
serialization,
serialize,
server,
webclient
Recently, I've been trying to find a challenging C# Project to work on. I've tried stuff like a program that tells you your WPM and then submits it to the highscore table. It wasn't really very challenging, although I did learn a thing or two. But the other day, I really hit the nail on the head: A C# Remote Desktop Host/Client.
Skip this paragraph if you already know what a Remote Desktop Host/Client is
A remote desktop host/client is a program that lets one person remotely control another person's desktop. So, for example, lets say I had a friend in california, and I live in north carolina. The person in california, using this program, could control my desktop and, say, create and populate a text document. The host is the program that lets you control the desktop that the client program is running on.
So in order to pull this off, I need to have two connections: One for the server to send information to the host, and one for the client to send information to the host. I was initially going to use Sockets, but that would only work over LAN. So I created some PHP scripts to communicate with the MySQL database to do things such as post a string to the output database [the input for the other side], and check for posts to the input database [the output for the other side]. Once I got all that working, I could use WebClient.DownloadString("Script.php"); to execute the script via C#. Both Get and Post parameters work with this.
Then I set up threads on the client and the host to check for messages multiple times per second. The main problem at this point was sending an Image, 1440x900px [my screen resolution], to the database quickly. Uploading and Downloading it directly would be far to slow, so I did a google search for "C# Image Serialization". I found a really good method, using base64 encoding, and it uploads fast. So the client would take a screenshot, encode it to base64, and send it to the database via PHP. Then the server would download the encoded image as a string, decode it into an image again, and display it. All this happening multiple times per second.
So all that is the theory behind it. I still have to implement the sending and receiving, but everything else is working properly.
Skip this paragraph if you already know what a Remote Desktop Host/Client is
A remote desktop host/client is a program that lets one person remotely control another person's desktop. So, for example, lets say I had a friend in california, and I live in north carolina. The person in california, using this program, could control my desktop and, say, create and populate a text document. The host is the program that lets you control the desktop that the client program is running on.
So in order to pull this off, I need to have two connections: One for the server to send information to the host, and one for the client to send information to the host. I was initially going to use Sockets, but that would only work over LAN. So I created some PHP scripts to communicate with the MySQL database to do things such as post a string to the output database [the input for the other side], and check for posts to the input database [the output for the other side]. Once I got all that working, I could use WebClient.DownloadString("Script.php"); to execute the script via C#. Both Get and Post parameters work with this.
Then I set up threads on the client and the host to check for messages multiple times per second. The main problem at this point was sending an Image, 1440x900px [my screen resolution], to the database quickly. Uploading and Downloading it directly would be far to slow, so I did a google search for "C# Image Serialization". I found a really good method, using base64 encoding, and it uploads fast. So the client would take a screenshot, encode it to base64, and send it to the database via PHP. Then the server would download the encoded image as a string, decode it into an image again, and display it. All this happening multiple times per second.
So all that is the theory behind it. I still have to implement the sending and receiving, but everything else is working properly.