|
-
Sep 21st, 2009, 07:59 AM
#1
Thread Starter
Lively Member
[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?
-
Oct 11th, 2009, 09:57 AM
#2
Hyperactive Member
Re: Control app via internet
You should manage to do it with asp.net. Take a look at some guides.
-
Oct 11th, 2009, 10:11 AM
#3
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?
-
Oct 11th, 2009, 08:13 PM
#4
Thread Starter
Lively Member
Re: Control app via internet
the program is made by me, also in vb
-
Oct 12th, 2009, 03:17 AM
#5
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
-
Oct 12th, 2009, 12:36 PM
#6
Thread Starter
Lively Member
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.
-
Oct 12th, 2009, 12:47 PM
#7
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?
-
Oct 12th, 2009, 01:03 PM
#8
Thread Starter
Lively Member
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?
-
Oct 13th, 2009, 03:51 AM
#9
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?
-
Oct 13th, 2009, 03:53 AM
#10
Thread Starter
Lively Member
Re: Control app via internet
they would be across the internet, but i was testng the app on my local net
-
Oct 13th, 2009, 04:02 AM
#11
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:
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..
-
Oct 13th, 2009, 04:20 AM
#12
Thread Starter
Lively Member
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
-
Oct 13th, 2009, 06:12 AM
#13
Lively Member
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.
-
Oct 13th, 2009, 08:15 AM
#14
Thread Starter
Lively Member
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?
-
Oct 13th, 2009, 08:30 AM
#15
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
-
Oct 13th, 2009, 08:52 AM
#16
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|