Network server help?

How could I communicate to my own server, assuming that I have one, and save information to it? (Im relatively new to Corona, and don’t know a lot about how Corona’s network functionality, so anything to get me started on something like this would be great lol).

Also, is there another way to communicate to a server besides communicating to a website? Like does Corona provide servers for you to use, or do I have to set up my own server or use a website?

This is what you wold use to comunicate with a custom server or a rest service or similar: network.request

You could use one of corona’s plugins to store data at a provider. I don’t know from the top of my head which ones. Check the plugins page.

When it comes to custom servers it all depends on your needs and skills. You can rent basically any kind of server on the web just google it but you have to know what you need first. Usualy it would be a rest server comunicating in json format or something similar if you need server side processing. For this you would need the ability to install a web service on the server. If you need it just to store files than a simple html server with some sort of authentication would be enough. It all depends on your needs. Any custom web services will have to be written by you of course.

Ok thanks. However, I don’t want to store data on a website that anyone can access. Will the network.request function still work for NO websites?

Or is there a way to have a “secret website” that only my app can access? I want to store like player stats, but don’t want the stats to be on a website where anyone can go to. Is there a way to do this?

The network.request() is set up to talk to a standard web server (Apache, Lightd, Microsoft IIS, etc).  It makes standard HTTP requests like GET, PUT, POST, DELETE and HEAD.

Lua supports sockets for other types of TCP/IP communications with other ports like FTP, SMTP, or your own socket protocols.  There should be examples in the community forums for dealing with this type of socket communications.

Rob

As I’ve said you can have a web server with authentication that you would code in your app but that is not very secure as someone can parse your app and get access to it. A much better way would be to code your own server (either HTTP based like SOAP, REST, … or TCP  that would handle authentication on a per user basis and store user data in a DB.

Ok thanks. So I should use the network when I want to get something from a website, and socket if I want to connect to my own server that is not a website? Or does network also work if I want to set up a server, and if so, then whats the difference between network and socket?

If you want to setup a server, you will need to use sockets.

The network.request() API is only for HTTP servers making HTTP requests.

Rob

You can write a custom server that is HTTP based (like SOAP, REST, …) These servers are easier to code as they handle the low level network comunication themselves, you only have to create and parse requests and responses. This servers are usualy state-less meaning one request one response and the server forgets everything. Every kind of http based server (I don’t mean a web page server as there can be only your service running on it and nothing else) can be accessed with network.request. If you want to have an open connection to the server with client or server making the requests then you would have to code a TCP server, but you have to handle every piece of network comunication, redundancy, error checks your self if you don’t start with something that is allready handeling this. Browse the web for it depending on what you need. If you use a server that is not HTTP based than you need to use lua sockets.

Ok thanks Rob. I feel honored having a Corona Staff member reply to my post as I just started Corona a few months ago lol :P.

So far, I love Corona! Keep up the good work!

Anyways, so I guess I’ll use sockets :P. It sounds more difficult to use, but is exactly what I want unlike the network functions. Thanks!

This is what you wold use to comunicate with a custom server or a rest service or similar: network.request

You could use one of corona’s plugins to store data at a provider. I don’t know from the top of my head which ones. Check the plugins page.

When it comes to custom servers it all depends on your needs and skills. You can rent basically any kind of server on the web just google it but you have to know what you need first. Usualy it would be a rest server comunicating in json format or something similar if you need server side processing. For this you would need the ability to install a web service on the server. If you need it just to store files than a simple html server with some sort of authentication would be enough. It all depends on your needs. Any custom web services will have to be written by you of course.

Ok thanks. However, I don’t want to store data on a website that anyone can access. Will the network.request function still work for NO websites?

Or is there a way to have a “secret website” that only my app can access? I want to store like player stats, but don’t want the stats to be on a website where anyone can go to. Is there a way to do this?

The network.request() is set up to talk to a standard web server (Apache, Lightd, Microsoft IIS, etc).  It makes standard HTTP requests like GET, PUT, POST, DELETE and HEAD.

Lua supports sockets for other types of TCP/IP communications with other ports like FTP, SMTP, or your own socket protocols.  There should be examples in the community forums for dealing with this type of socket communications.

Rob

As I’ve said you can have a web server with authentication that you would code in your app but that is not very secure as someone can parse your app and get access to it. A much better way would be to code your own server (either HTTP based like SOAP, REST, … or TCP  that would handle authentication on a per user basis and store user data in a DB.

Ok thanks. So I should use the network when I want to get something from a website, and socket if I want to connect to my own server that is not a website? Or does network also work if I want to set up a server, and if so, then whats the difference between network and socket?

If you want to setup a server, you will need to use sockets.

The network.request() API is only for HTTP servers making HTTP requests.

Rob

You can write a custom server that is HTTP based (like SOAP, REST, …) These servers are easier to code as they handle the low level network comunication themselves, you only have to create and parse requests and responses. This servers are usualy state-less meaning one request one response and the server forgets everything. Every kind of http based server (I don’t mean a web page server as there can be only your service running on it and nothing else) can be accessed with network.request. If you want to have an open connection to the server with client or server making the requests then you would have to code a TCP server, but you have to handle every piece of network comunication, redundancy, error checks your self if you don’t start with something that is allready handeling this. Browse the web for it depending on what you need. If you use a server that is not HTTP based than you need to use lua sockets.

Ok thanks Rob. I feel honored having a Corona Staff member reply to my post as I just started Corona a few months ago lol :P.

So far, I love Corona! Keep up the good work!

Anyways, so I guess I’ll use sockets :P. It sounds more difficult to use, but is exactly what I want unlike the network functions. Thanks!