Advertisement

Help me get started with a "Hello World" game that uses a server?

Started by May 08, 2015 06:46 PM
8 comments, last by Brain 9 years, 8 months ago

Hi all, thanks for taking the time to read! Here is what I am trying to do:

I want to make a simple website that shows you a simple frame. The first time you click in the frame, the website drops a zero into the frame where you clicked. It then starts counting up from zero where you clicked. I want the counting to take place on the server.

I know that I could do this without counting on the server, but I am doing this as a learning project to learn how to write a service. The only part I do not know how to do is to get the counting to run on a remote server that I do not own. If I need to rent, that is fine, but I am not sure where to search to compare the cost of renting servers. I have an account on iPage that provides a SQL database and cloud storage, but so far it looks like they do not provide the option to have any custom server side processing running.

Thanks again for taking the time to read. Any help greatly appreciated!

What you want can't be done with just a pure website, and sql(well it could, but would be terribly inefficent).

Since this is for learning, what you want to do is probably only to be done at home locally. Since you want to use a browser to output to, you should look into using websockets to communicate with your server application.

Basically the idea here is that when you open the webpage, it creates an websocket connection to your server at home, on a port of your choosing. Since you absoultely want the server to control the counting, what you can do is that the server periodically sends to each connected client, the location of all the numbers, and the current count. Then the client will draw out all the info.

Now when a client clicks somewhere, they send a message to the server of where they clicked, then the server will add it to the list of numbers to track, and increment.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement

Thanks slicer4ever, I think I will try that. I am a bit worried about opening ports on my PC so I wanted to do it on an external server, but I suppose learning how to manage the whole security aspect could be interesting as well. I'm guessing I can open the port for an hour or so each time I test the app and then close it afterwards until I learn a better method.

You can look into DigitalOcean for your hosting server they give you full terminal control of the server for $5 a month per server. You can go from there to install nodejs and socket.io I am sure you will find a good tutorial on either of those and how to make it communicate with the webpage. I think the first one is making a simple chat program using those but you can easily switch to a bidding system or anything you want. I hope this helps point you in the right direction.

Here socket io has one http://socket.io/get-started/chat/

Also over at http://livecoding.tv they had someone who created a nodejs game server, and all the videos archive so you can go back too. This site is free and you can even watch programming code live and chat with them.

Thanks wicked250, that's exactly what I was looking for!

Thanks slicer4ever, I think I will try that. I am a bit worried about opening ports on my PC so I wanted to do it on an external server, but I suppose learning how to manage the whole security aspect could be interesting as well. I'm guessing I can open the port for an hour or so each time I test the app and then close it afterwards until I learn a better method.


This is what port forwarding is for on your router. For most everybody at home, When you connect to a router to your modem, the router is given a public ip addresss, when your pc goes to talk to other servers on the internet, those servers only see that routers ip address, and not your pc, so they can only talk to your pc if they respond on the socket that initiated contact with them. With port forwarding you tell your router that if anything comes in on a certain port, you forward that traffic to computer x. So long as you don't setup port forwarding, no outside computers can talk to your pc on that port.


Secondly opening a port isn't inheritly harmful, i think you've been mislead in this regard. The problem isn't with the port being open, it is the software behind the port, if someone finds an exploit within your software that allows you to download malicious software and run it unknowingly, that is the issue. But very simple telnet like applications are going to be hard pressed to find such exploits, in addition it'd require an extremly talented hacker to not only find you, but somehow discover such a compromising bug in your server software as well.

Every site you access with your browser is likely to be more harmful than anything you are making right now.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement

Thanks slicer4ever, that does make me feel safer trying it at home first. Also, I checked out your games on youtube, really cool stuff!


Secondly opening a port isn't inheritly harmful, i think you've been mislead in this regard. The problem isn't with the port being open, it is the software behind the port, if someone finds an exploit within your software that allows you to download malicious software and run it unknowingly, that is the issue. But very simple telnet like applications are going to be hard pressed to find such exploits, in addition it'd require an extremly talented hacker to not only find you, but somehow discover such a compromising bug in your server software as well.

Seconding this. Firewalls have become common, but they're really a sledgehammer approach to security. If you don't have an application running with a local socket bound to the port in question then incoming connections will simply fail. I've had my PC configured as my router's DMZ for a long time now and the worst that's happened is the occasional anonymous port sniff. There's nothing listening on my machine that's not been secured, so there's no real security risk. Where firewalls are actually useful is in notifying you when an application on your machine tries to bind a socket. If something is trying to listen for your connections without permission then you should take an interest in that ASAP.

That said, if you ever do consider going DMZ, you'll want to check for updates and security info first to make sure that your OS doesn't have any glaring security holes.

As for port forwarding, since you're doing active development, you'll know right away if there's a risk because a port can't be bound more than once at a time. If you have a program that you've written that's trying to listen on port 1234 and it complains that it can't bind the port then that probably means that some other program already has it bound. You'll want to check to make sure that whatever is binding the port is legitimate, and if so then just pick a different port number.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
I second (or third) the above comments on security. Firewalls are overrated and overpriced. There is a much simpler and cost effective way to secure your computers and networks...






20066820.png

I second (or third) the above comments on security. Firewalls are overrated and overpriced. There is a much simpler and cost effective way to secure your computers and networks...






20066820.png

You're using this security tool on the wrong cable.

If you really want to be sure, you need to secure the PC against physical access too, and you should buy the "ScissorsTM insulation pack", and then use the ScissorsTM system to slice up every cable in the PC, making it harder to hack even if the intruder has physical access. :lol:

This topic is closed to new replies.

Advertisement