8 posts
Posted 13 October 2014 - 06:15 AM
I want to connect to a computercraft computer from the internet. I have some experience fetching data using the http api, but I have no clue how to attempt this. I want the cc computer to listen for a request and setup a connection. I dont know what port to use or if this is possible. I would explain the big picture of the project, but I dont want to give it away just yet. I normally use a dynamic DNS client on the server so the ip should not be a problem. Thanks in advance.
7083 posts
Location
Tasmania (AU)
Posted 13 October 2014 - 06:34 AM
The short answer is you can't.
The long answer is that a CC computer can't accept an incoming connection (there's simply no functionality to allow you to do so), but it can keep tabs on a webpage stored on a remote server (eg: pastebin) and pick up messages from there. Sort of like using post-it notes to communicate with someone - you just leave them somewhere you'd expect them to be found, and the recipient will check for them when they're good and ready to do so.
8 posts
Posted 13 October 2014 - 06:39 AM
Thanks for the quick reply. I was afraid I would have to do that. I basically want to ssh into a cc computer from the internet, but im not sure how possible it is.
1 posts
Posted 13 October 2014 - 08:16 PM
You could set up a webserver with some server side scripting language (php/python…).
Each cc computer could send its own id and answers (if needed) periodically as post values to the server.
The server then sends the command to execute (if any) as answer.
It would be wise to add some password to only allow access for yourself.
Then you can add a web interface to control each cc computer.
Its not nice, but as far as i see, the only way doing this with cc.
*I guess i'll build something like this in python. Will post when done*
808 posts
Posted 13 October 2014 - 08:52 PM
There's the long poll technique. Have a CC computer send a request to the server, and have the server not respond until it's got something for the computer.
Computer: Hey let people connect to me
Server: … (later) … ok this guy wants to connect.
Computer: Finally. Give him this.
Server: … (later) … He said this.
8 posts
Posted 18 October 2014 - 07:09 AM
I just got done making my prototype. If anybody has any uses for this, then use it.
I made a html page that sends the code to a php file called send.php. This processes the command and shows the result to the CC computer. In order to keep the computer from executing the same code time after time, I made a counter on the webserver that counts the submits. The web page should be phone friendly.
I use a apache web server on the minecraft server. Its easy to do with an Ubuntu Server, no gui.
Here is a short video to demonstrate it. I might be confusing, but its my first video.
Spoiler
[media]http://youtu.be/hqxkHShLWVg[/media]Here are the php files.
send.php -
http://pastebin.com/8wb4FrSVcount.php -
http://pastebin.com/MpfHsinwThanks for the help.
Edited on 18 October 2014 - 05:10 AM