This is a simple app to demonstrate listener and client Sockets/Remote program execution, and so on.
Environment: VC6, NT4, Win9x
First of all, let me thank all the contributors to codeguru.com; your knowledge and expertise has helped me tremendously. You will see I’m using many code snippets from them in many of my applications.
I’m submitting this simple and very basic CSocket program due to the large number of requests I receive almost every day from the codeguru VC++ discussion board. Experienced programmers will find this simple and easy to develop, but I guess the beginners will get a good introduction to CSockets and its raw power.
There are two applications I’m submitting here: SockCommander (SC) and SockListener (SL). SL acts as the server and listens on port 777. This application must be run on that PC which you intend to control (well… in a way). Take down the IP address shown there and then execute SC on that PC from where you intend to control the server. Enter the IP address you got from the server in the relevant edit box in SC and press Connect. If successful, a message will be displayed both on SC and SL, saying ‘Connected’. Now to the interesting part. You can now send commands/messages to the server from now onwards by just entering the command on the Command/Msg edit box and pressing the Send button.
At the moment commands available for SockCommander are:
|CMD: <your command>||Sends a command thats to be executed at SockListener e.g CMD:Notepad.Exe will execute notepad at SL|
|FILEGET: <path of file to retrieve>||Retrieves small files from SL. This is still under test stage, not to be used for big files. e.g FILEGET:c:\msdos.sys (don’t forget to enter a valid filepath in the File Save as edit box)|
|!SHUT||Shuts down SL|
The possibilities of these apps are tremendous in the hands of a creative/thinking programmer!
All the best and Happy coding.