You really wouldn’t make a “terminal” though I suppose you could. Instead you can install something like phpMySQL which gives you a web interface to MySQL or an alternate like Adminer (not Ad-Miner, which will sometimes trigger malware scanners, but Admin-er, it’s legit).
Or do what I did for my Trivia game and build custom PHP-MySQL-HTML5 forms to do admin tasks from a web browser. I had an account management screen and a question management screen. By having custom forms, it makes hiring help easier if they don’t need to know how to query a database but can search by emails and type and submit.
Now to all of this discussion about using sockets vs. web requests. It comes down to core speed. HTTP/HTTPS requests are simply slow. Corona has to open a previously unopened port, which requires an DNS lookup and then ask the webserver to request a page. The webserver, usually Apache has to parse the request, split out the GET or POST key-value pair parameters, start up a PHP session, which has to interpret your script, which has to open your SQL database and run the query, encode the data, output it and the webserver has to send it back. Sounds awful, but we are talking half a second to a couple of seconds to make a query assuming the server is playing nicely. Your connection is closed and the webserver can go on to talking to someone else.
This is perfectly fine is for turn based games or games like my trivia game. For some chat/messaging systems this is probably fast enough too.
Sockets are the basis that everything works on. HTTP web servers, FTP servers, Mail servers, etc. all are making some form of socket connection to do the work. The reason we discourage it, is an HTTP request can be done in one line of code and a function to handle the results. All you need is a URL. That’s pretty simple. With sockets, you have to open the socket and bind to it, once you have the connection established, you have to understand the protocol the server is talking and format your packets accordingly. Your server has to know how to unpack said packets arbitrarily operate on them and return some result. It’s considerably more work than making a network request. So why do it… Because it’s fast. If you have a good connection to the server, you can be exchanging messages in times measured in milliseconds instead of thousands of milliseconds. Your server needs to take that data and get it to your other players with the same speed. You don’t disconnect from the server until you’re done so each message doesn’t suffer the startup-connection overhead. HTTP cannot do this. Now of course somewhere along the way someone created Web Sockets which in a nutshell is a long lasting connection to the web server. I’ve never used them but a Corona user David Mccuskey created something called DMC Web Sockets. http://docs.davidmccuskey.com/getting+started±+dmc-websockets
GameSparks, one of our third-party partners who does games as a backend service actually uses his library for their plugin.
This can get you in between having to write low-level socket code and HTTP requests. You might want to look into it if you find HTTP requests are too slow for your needs.
Now to the question asked waaaaay back up at the top.
Unless your client and server are running on the same device, both of them cannot connect to “localhost”. “localhost” means “connect to myself” or “listen to myself”. It’s perfectly fine for servers to listen using “localhost”, but your client usually needs a domain name or IP address to connect to*.
* not recommended to connect to an IP address as they change, make sure to setup a DNS record and give your server name that can still exist if the IP address behind it changes.
Rob