Reputation: 11848
Sorry for the rather ignorant question, but I'm a bit confused regarding these two technologies. I wrote a webserver in C# that uses Fleck and everything works great but I realized I probably couldn't find a hosting provider that would run .NET applications.
I want to use websockets and I found socket.io to be really popular but I'm not sure exactly what it is. Correct me if I'm wrong, but, is it just like writing a server in javascript and you run the javascript file with the node.exe
application and then the server is running? How do people find hosting providers that will provide that sort of service?
Lastly, is socket.io just an extension of nodejs? Do you have to code your server in javascript when you use socket.io? Again, sorry for the very novice questions but I'm just trying to understand a few basic things before I continue. Thanks.
Upvotes: 1
Views: 456
Reputation: 1967
@travis has already covered everything you need to know about node and socket.io
I'd only like to say that you don't have to buy a special
hosting dedicated for node.
My game is hosted on VPS with Ubuntu
I find it really easy to deploy and maintain. There is a package for Ubuntu and instalation takes literally four lines of copy/paste
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
ps: I am not using socket.io but einaros/ws library which I find much less overblown.
Upvotes: 0
Reputation: 8615
There are a few companies that will host your node application. Its not the same as your transitional web hosts where you provide them with files and they serve the files for you. When working with node you're writing the actual web server.
Some of the popular ones around are below:
@Roest: A virtual server sounds intriguing. What are the pros and cons of such an approach? Also, considering how popular nodejs is how can its webserver hosting support be so limited? How do people use it?
When working with a virtual server you have full rain over what your running on the server.
Pros Freedom, you get to pick all the software you want to run on your machine. A lot of the times when working with nodejs you're going to want some custom software to be running along side your application. Most of the time this is your database layer, which ever you choose.
Cons YOU have to maintain it. Like @Roest stated, this isn't much of a con for most people as this ties directly into the freedom a virtual server gives you but it is something you need to take into account.
I think the reason you see limited support for nodejs is because its relatively new, and its so easy to setup yourself.
I want to use websockets and I found socket.io to be really popular but I'm not sure exactly what it is. Correct me if I'm wrong, but, is it just like writing a server in javascript and you run the javascript file with the
node.exe
application and then the server is running?
That's pretty much exactly what nodejs is, or at least how you use it. Nodejs itself is Google's V8 javascript engine running on your server, along with a large number of libraries and C bindings that allow you to interact with your server in a way that the V8 engine won't let you.
This is an example of a webserver in nodejs (A very limited one)
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
It just responses Hello World
to every request and always returns a 200 status code.
Going from something like this to a simple file server is fairly easy and quick, but a few people have already tackled this problem for you.
http://expressjs.com/ - Very powerful web server, but still gives you a lot of freedoms. https://github.com/nodeapps/http-server - Simple web server, I use it mainly as a command line tool to instantly server files over http.
Lastly, is socket.io just an extension of nodejs? Do you have to code your server in javascript when you use socket.io? Again, sorry for the very novice questions but I'm just trying to understand a few basic things before I continue. Thanks.
socket.io among many others is a module of nodejs. Depending on your definition of extension it may be the wrong word to use. Most of the time when using socket.io you'r going to be using an existing http server and then extending, or wrapping your server with socket.io. I wrote a previous explanation of how nowjs does this. My guess is socket.io is very similar.
To answer the bulk of that question: Yes, you will still be writing your code in javascript. You will just be utilizing the socket.io API.
Upvotes: 3