Where does the server side of programs run? [closed] - java

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program? Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons. For example: where would a small scale indie online game run their server side from?

If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
a computer?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program?
a website is a kind of application run on a server, they are not servers.
Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons.
there is no "obvious" reasons why. Many web services started self hosted, and Internet has been built with service providers that are not in datacenters. I do host many services at home and they are accessible from Internet.
For example: where would a small scale indie online game run their server side from?
You have many choices:
a server on a pretty good Internet connection at your home/workplace/garage (with enough bandwidth and low latency),
a virtual server hosted in a datacenter service's provider,
a virtual server like AWS/EC2, Google apps, Azure...
a dedicated server in a datacenter,
a grape of dedicated servers and their caches etc.. with many engineers making the thing work perfectly
...
it all depends on the money you got!

websites are NOT servers. Servers are servers, and host websites (among other things). The "server" is the thing that people connect to, aka a physical machine. This machine may or may not be the same machine as your client.
For an indie game, it depends on your connection. Your options are to either run it yourself out of your room, which is entirely fine provided you have a good internet connection, or to RENT server space, which is some cluster somewhere that you rent access to. These usually have external tech support for when things go wrong.
If you are testing code, run the server software on your local machine. once you get it working, run it on a different computer on your local network. once that works, run it on an external network.
Also, for reference, I run a web/file/computational/etc server out of my bedroom. It keeps me warm in the winter.

A Java web application runs inside an application container such as GlassFish or Tomcat (there are many others). This container runs on a physical server. Typically the physical server will be hosted in a server room of some kind. This can either be at the companies location or, more common for smaller companies, remotely hosted. A remotely hosted server can be a physical piece of hardware you own or more commonly now just a machine you rent, in fact most servers you'd probably rent now will be virtualized.
You can run a web server from a home computer, I've done it for many years, but it has some downsides. You typically have a fairly poor internet connection and a lot of ISP's don't like you hosting servers.
I recommend you look at renting a virtual server.

Related

Java NTP Implementation

I have a server/client application and I need to synchronize the time of the clients with the time of the server. Thereby I need to implement an NTP Server (or similar) on the server application and an NTP client on the client side.
NTP is not a requirement, but it has to be accurate for at least 50ms (then it would be already a bit critical, but still usable, until I figure out a better solution).
Does anyone have any advices, if there is a good implementation that could help me, or if it's doable to implement this by myself (with the desired precision).
Edit: More information about the project
The server application runs on a customers Home PC. The computer of the customer does not have to change the time, only the client (which is running on a dedicated computer, running on Ubuntu).
This is an IoT project, there are many clients that are very small hardwar devices and should have the same date/time as the server. Because the client won't fiddle with the client's configuration, and he does not have access to it (it's a blackbox), I can run my application using admin rights, if needed.
I don't want to install an NTP Server on my client's home PC. This is the reason I want to deliver this functionality inside of my Java Application.
There's a NtpClient in apache commons-net that you can use for this. You can use this to figure out the clock drift at least of your client pc and try to compensate for that.

How to put Java ServerSocket online?

I have a Java program that uses ServerSocket to listen for connections on my local port. I want to put this online so other people can also run the client and connect. I just want the host to literally run my .java program in an infinite loop. All the cloud hosting sites talk about Apache, Maven, and databases but that all goes over my head. How can I get them to run my .java file in an infinite loop so people worldwide can connect to the server socket?
You can have your own server at home, you only need to contract to your Internet Service Provider and they will give you a publc IP and your server will be public.
Another option is to contract a cloud server like Amazon EC2, they have an option and give you a basic server free for a year.
https://aws.amazon.com/es/ec2/
Or you can contract a VPS virtual private server, it's a dedicated server online for you, it's like EC2 but without virtual machines

How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am working on a game and I am thinking about getting into networking. I have been programming for about 5 years and got into game development the last 2 years. I only really learn online and from books on my own time. I am planning to make a java server for Amazon AWS EC2, but I am just wondering how MMO's handle multiple players each tick.
Is it just the sheer power of servers? I am not looking for code or anything, just in general how the servers work.
Does the server just do all of the calculations for all of the players and the tens or hundreds of thousands of objects and then send and receive thousands of packets every tick? It just seems like a lot for a single computer to handle, but it is indeed a server.
How work and what is the job of a server?
Your server create a socket and open a port.
The protocol for an online game is generally in UDP because it is faster.
Your server have to handle ALL the clients connections.
You can add a server who is able to log an account and redirect him into a game server (this is the case for all the big MMO).
Your server have to manage all the calculations from the Data Base: when an enemy hit another enemy, subtract a part of your money when you buy some stuffs...
So the server is the main part of an online game.
In fact, a computer is really fast for do some calculations, the most heavy part for a modern video game is the physics and graphics... Fortunately, these both parts are on the client part.
But, a server have to be strong! Not like a client because he doesn't need a big GPU, but he need a big amount of RAM/CPU (depend of the game) and he also need to stay cold.
In fact, a game server is able to handle a large amounts of connections because of the UDP protocol and because all the heavy parts of the program are on the client side. You can take a look here: Creating a Multiplayer game in python and read the part when I explain the difference between the UDP and the TCP protocol.
All the others informations about how work an MMO server are linked at the end of this topic.
Now we can try to build a server!
Firstly, do you know how to create a server?
Program or download a server for do a test (example: TeamSpeak or Mumble).
Launch him from your computer and allow his input connections from your firewall.
Log you on your modem and forward/redirect the port of your server into your computer.
For the last part, you need to do some research: Which port is used by my server and how to forward a port with my modem (each modem is different).
Now you can try to log you into your server. But...!
Your computer have three IPs:
The Loopback address: localhost, 127.0.0.0 (The "0" can change)
The Intranet address (IP linked to your computer): 192.168.0.0, 172.16.0.0, 10.0.0.0
And the internet address (IP linked to your modem): 0.0.0.0
How to know your Intranet/internet IP? That depend of your Operating System and your modem. For the Intranet use your terminal and write "ifconfig" or "ipconfig". For your internet address, it is sometime write when you log you to your modem, or you have to visit a website who is able to show you your IP.
If you create a server and you didn't forward the port from your modem, you can still access to your server in local with your Loopback address and the others computers connected to the same modem can also access to the server with the Intranet address. Also, if you need to test if your server is accessible from internet, you have to test the connection with your internet IP, but some modem don't allow the externals connections from the Intranet... So if your connection with the internet IP doesn't work, try to log you to your server from another modem (friend's PC, Cyber-Coffee...).
Lastly, how to protect your server?
This is really difficult and you cannot create a perfect security... Especially if you follow my advices but you didn't complete my knowledge with your own research.
Root access
This is the most important part. When a lamer try to access to your server, he can just try a simple connection like the http/ssh/ftp. If he can access to your hard disk and you haven't chose a strong restriction, he can simply read/modify/delete the Data Base of your game. The Data Base contain all the informations about the accounts.
Firewall
We have already talk about the amount of connections/calculation than a server have to handle. In some attack, the lamer try to create a big amount of connections and didn't close them. We call that a DOS (with 1 computer) or DDOS (more than 1 computer). So you need a good firewall for: allow only the port of your server, allow only X numbers of connections from an unique IP and allow only X numbers of new connections every minutes.
Updates
This is the easiest part: keep your Operating System (and the others applications) up to date.
Less is better
Don't install many useless software to your server. If a software is not import for your server, you shouldn't install him because: firstly, that can be a virus. Secondly, a malware can exploit this software for install a virus or steal the root access.
Encryption
The encryption is really important for block an Hacker. For example, with the https protocol you can protected the user's passwords from the MITM attack. And with the Bluefish/SHA/others, you can encrypt your Data Base for protect her even if an Hacker can read it. The most important is always to block the write/modify/deletion/execute right of the Hacker (in fact, all the clients of your game need the read access).
Anti-virus?
In the case of an online-game, an anti-virus is not really important (But still recommended for all Operating System, Linux/Unix also).
Have a good server
If your server is programmed without take care of the security, you can be in trouble. Example: Buffer Overflow attack in C/C++.
If you need more informations about how work an MMO, I recommend you:
http://electronics.howstuffworks.com/mmorpg6.htm
https://en.wikipedia.org/wiki/Server_%28computing%29
https://en.wikipedia.org/wiki/Game_server
https://www.quora.com/How-do-I-create-an-MMORPG
Hint - If you are interesting by create an online game, you have to do many research, I cannot really answer in this question because is not the purpose of the subject. And this subject is too large for write a new answer at each question... Which software use for program a game? How to build a socket? Where started? But I have already answer at some similar questions. Even if the programming language are sometime different, I give you the link, the logic is always the same so it can maybe help you:
Creating a Multiplayer game in python
Xcode Mass Multiplayer (Not What You're Probably Thinking)
Multiplayer game in Java. Connect client (player) to game that was created by other client
Most MMO's have a healthy amount of client logic so that the server doesn't need to send multitudes of packets to every player all the time. The server doesn't do calculations for all players, the client does the heavy lifting and the server deals with the clients and the state of the virtual world in a database.
For example, your client and server could have the same world model. That way your player can navigate the world and the client code tell the server on a fairly course interval (say 100's of msecs).
Generally you want your clients to update themselves to the server, and have the server response deal with keeping the clients in sync.
MMOs also run multiple servers in their farms, from tens to hundreds. These servers typically talk to a large high-performance database - basically the state of the virtual world is in the database, and the servers sit in between keeping the database up to date and communicating to the client apps.

communicate with another applications on the same machine

Hi Stack Exchange Experts,
I am working on a task, that requires me to communicate with another applications on the same machine.
the machine is a Windows 7 laptop.
There are in total 3 applications on the laptop. Their specifications are given below:
First application is coded in java and runs on a local Tomcat at port 6060
Second application is coded in java and runs on Tomcat at port 8080
Third application is coded in java and does not have Tomcat. It is a static web application.
Since application 1 and 2 are running on Tomcat, I have used HTTP to commicate with each other. However, since they are on the same machine, is there any ohter way for them to commincate with each other?
Application 2 needs to communicate with application 3. What is the best way for this communication.
Please let me know if you require any further information to answer my queries.
Thanks.

Amazon ec2 with windows 2008 server with TOMCAT

I just created a free ec2 account. I want to test few things but i want to make sure that i am using ONLY the free version.
I want to run a java application in windows 2008 R2 server with TOMCAT as web server. Ec2 by default doesn't have java SDK and TOMCAT installed.
SO here are the few queries
Will i be charged for installing TOMCAT and JAVA also for deploying my application?
How do i install TOMCAT and JAVA ? can someone provide a link?
I tried doing a remote desktop ut could not connect to the server. Looks like a firewall issue. But then how do i disable ?
Can't answer all your questions, but I'll take a shot.
If you want to watch your ec2 cost, setup a billing alert in AWS that will notify you when your account exceeds a certain threshold, and set your threshold very low if you are very concerend. You can always monitor your outstanding charges on your billing page on a daily basis if you are really concerned.
Pick a small or micro instance if you want to keep your costs low; micro instances I have found are mostly useless for any serious work, but they are very, very cheap and maybe ok for trying things out.
To install any software, you are going to need to get remote desktop working. Once the server is spun up, remote in and you can install anything you want; there is no extra cost to install software (except buying licenses if you need them, but that is not aws's concern, they won't be charging you for installing tomcat.
You need to open up the windows firewall on your 2008 server AND you need to make sure the AWS security group also allows incoming connections on port 3389 - its essentially there firewall that runs in addition to the EC2 instances firewall - BOTH need to be open. You can either modify the security group that was assigned to your instance, or create a new one and associated it with your instance.

Categories