Results 1 to 16 of 16

Thread: [RESOLVED] Control app via internet

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Resolved [RESOLVED] Control app via internet

    I have a app that sends me a text message to my cell when my pc starts up. i want to be able to send that app a "packet" or "signal" via the internet to control somesort of action like run a program or pop up a pre defined message or even shut the pc down. im not sure how to send packets or recieve them if its even possible, i know there will be some port forwarding needed on my routers end and i can do that part. Anyone know if this is possible?

  2. #2
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Control app via internet

    You should manage to do it with asp.net. Take a look at some guides.

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    ASP.NET has got absolutely nothing to do with what has been asked...

    This program that you want to send a signal to, is it a program of your own or is it a third party program that you have no access to the source code of?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    the program is made by me, also in vb

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    Then you need to look into the TCPClient and TCPListener classes. JMC just made a wrapper around these classes that makes them easier to use and hides some of their complexity so if you are struggling then you might want to check it out: http://www.vbforums.com/showthread.php?t=587341
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    that wrapper seems to be more towards sending messages to other users with the client? am i right? Im trying to send commands to other apps. for example one of my apps shuts down the computer, i want to be able to send a command to that app and it will execute the shutdown.

  7. #7
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    OK but the program receiving this 'signal' must be aware of the fact that it is going to receive these signals and execute certain commands. So you need to have some kind of 'client' in the target application that can receive these commands, otherwise how on earth would it work?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    ok, well im running his server on one pc and client on another but it wont connect? is there anything that needs to be modified or should it work on its own? How does the client know what ip to attempt to connect to?

  9. #9
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    I would imagine there is a part where you have to enter the IP to send to and to listen on, I havent actually used it myself though.
    Also, how are these 2 PCs connected? On the same network or are you doing it across the internet?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    they would be across the internet, but i was testng the app on my local net

  11. #11
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    OK well I just had a very quick look at that link I sent you to JMC's wrapper and instantly saw this code example in his first post in there:

    vb Code:
    1. Private WithEvents client As New MessageClient(hostName, remotePort)

    All you need to do is replace "hostname" with the IP you want the client to connect to and replace "remotePort" with the port number.

    In the case of the client, the host name and remote port and the name or address and port number of the server. In the case of the server, the port is the port number to listen on. The server's port and the client's remote port must be the same.
    You could have at least read his post fully before trying to use it..
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    i did, and i saw that part but i fuiguired it was only for adding that ref to your own project, i thought the project he created might be configuired for that or something...i will give it a try later..thanks

  13. #13
    Lively Member
    Join Date
    Mar 2007
    Location
    ZA
    Posts
    65

    Re: Control app via internet

    Another thing to remember is that if you have some sort of firewall running then you need to open the port for the application to communicate through. Otherwise the firewall will block the application and everything just hangs especially if the TimeOuts aren't setup right.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    First off im a idiot, you were right, i just plugged in the ip and port and it works fine on my local net. Now how abouts can i use this to my requirements? just convert the text that i send to the server to a command?

  15. #15
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Control app via internet

    Yeah pretty much, define your own command structure and just make the server side understand the commands you are sending it. For example you could send the commands in separate 'sections' that are split up by a special character such as the | character. So you could send "OPEN|CMD.EXE|NOW" and your server would split the received string up by using the String.Split method and passing the | character in, then it would look at each individual part in order and see what it is supposed to do. Obviously in that example I am assuming that your first part would tell it what to do (ie, OPEN could start a program, SHUTDOWN could shut the PC down etc etc), the second part tells it what program to open (you could just pass this straight to Process.Start to launch it) and the third part tells it what time to execute the command - obviously NOW would be a special case where it just does it instantly.
    You might not need all that, maybe you dont need it to be that flexible and it just needs to respond to one or two commands but I thought I would just throw some ideas out there.

    One thing I will say though if you go down this route is: think about security. Make it so that your server has to receive a password before any commands for example, so that not just anyone can send your program a string of text on the correct port and it will execute whatever they tell it. That doesnt make it completely secure as someone could be 'sniffing' your incoming traffic and because the command is just plain text then they could see the password but it depends how secure you want this to be
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  16. #16

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    108

    Re: Control app via internet

    ok, sounds good. thanks for the help chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width