• Apache Tomcat vs. Writing your own server in Java.
    17 replies, posted
I'm not very familiar with Tomcat, or Apache in general. But overall, which is better for, hypothetically speaking, a multiplayer game or a website? Is Apache Tomcat convenient for all types of applications? Is it simpler than setting up socket connections with java.net?
Game networking is wildly different than hosting a website. Game networking is typically done over UDP, you don't care if you miss a world frame, and you're most likely using your own binary protocol to keep ping low. Hosting a website is basically implementing HTTP, which works on top of TCP since reliability is a much more important factor than speed. There is no one-size-fits-all for all networking needs. Yes, it's much better to use a pre-made server like Apache than write your own, but no it won't work at all for a multiplayer game.
[QUOTE=robmaister12;36727822]Game networking is wildly different than hosting a website. Game networking is typically done over UDP, you don't care if you miss a world frame, and you're most likely using your own binary protocol to keep ping low. Hosting a website is basically implementing HTTP, which works on top of TCP since reliability is a much more important factor than speed. There is no one-size-fits-all for all networking needs. Yes, it's much better to use a pre-made server like Apache than write your own, but no it won't work at all for a multiplayer game.[/QUOTE] So write your own server if making a game? And use Tomcat for everything else? Why isn't implementing Tomcat for games possible? I apologize in advance if what I'm asking is incredibly stupid. And would I be able to use Apache Tomcat for say, a IM app?
[QUOTE=Cockman;36727952]So write your own server if making a game? And use Tomcat for everything else? Why isn't implementing Tomcat for games possible? I apologize in advance if what I'm asking is incredibly stupid. And would I be able to use Apache Tomcat for say, a IM app?[/QUOTE] Tomcat is an HTTP server. HTTP is a very bulky and slow protocol designed to be reliable and as descriptive as possible. When a client requests data from a server, the client sends over a useragent string, and when the server sends back a lengthy response header including information about itself and the response data. And this is (almost always) done over TCP, which guarantees that packets arrive in order and sometimes queues up a bunch of packets before making a transmission. You incur a huge overhead by using TCP and an even bigger overhead by trying to use HTTP. Your ping will likely be > 500ms and you're going to start hitting bandwidth limits clientside very quickly. A game doesn't need to know that much information about the server past initialization (maybe a version number check), the server doesn't need to know much about the client, and you don't need a full HTTP header attached to each packet. In the game I'm working on, the only semblance of a header is a single byte for a command id (up to 256 commands). And a binary packet format saves you a ton of space and keeps bandwidth low. Since most of your packets are going to be updating the positions and velocities of objects, you don't care if you miss a packet, so you can switch to UDP and build your own small reliability layer to make sure that necessary packets (eg player joined) arrive. Each packet in my game is only a few bytes, each client only transmits about 300 bytes per frame (60 frames per second, so 20kb/s per client). A single HTTP packet can be far more than 300 bytes, as you can see in this image I found on wikipedia: [img]http://upload.wikimedia.org/wikipedia/commons/c/c6/Http_request_telnet_ubuntu.png[/img] And instant messaging has it's own protocols, I'm sure there are other IM server programs out there, but you can try to set up an IM application that works over HTTP, it's been done before.
Also, HTTP is request/response-oriented. The server sits and waits for the client to ask for something, and then sends what the client asked for. There are [url=https://en.wikipedia.org/wiki/Push_technology]some ways[/url] to simulate the server being able to proactively send something to a waiting client, but it's not really well-suited to the sort of two-way continuous streaming that online games typically need.
Read This: [url]http://gafferongames.com/networking-for-game-programmers/[/url]
Avoid using a HTTP server for stuff like games or the like. They'll add unneccesary overhead, and it would be cleaner simply using something like TCP/UDP, as mentioned earlier.
Is Tomcat good for using with JDBC (MySQL connectivity)? Or can I code my own server that receives SQL queries through JDBC? Also, what is XAMPP? From what I know it's a web-server like Tomcat, but just with a different protocol (?).
[QUOTE=Cockman;36731564]Is Tomcat good for using with JDBC (MySQL connectivity)? Or can I code my own server that receives SQL queries through JDBC? Also, what is XAMPP? From what I know it's a web-server like Tomcat, but just with a different protocol (?).[/QUOTE] XAMPP is for web development purposes, it has a bunch of services rolled into one package and IIRC it uses apache as its web server. [editline]11th July 2012[/editline] and it uses HTTP.
[QUOTE=Cockman;36731564]Is Tomcat good for using with JDBC (MySQL connectivity)?[/QUOTE] Yes, you can use JDBC in Tomcat. Actually, you canuse JDBC in any Java program, but Tomcat lets you configure your database connection the [url=https://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html]Java EE way[/url], where all the parameters are kept in a standardized XML file that Tomcat understands, so your own code doesn't have to concern itself with things like the database username and password. [QUOTE=Cockman;36731564]Or can I code my own server that receives SQL queries through JDBC?[/QUOTE] JDBC is for [i]sending[/i] SQL queries to a database and receiving the query results. If you want to [i]receive[/i] SQL queries from another application, you'll have to roll that part yourself. But a typical web application doesn't do that.
My mind has been officially blown here; this is something I have been looking for. Thank you robmaister12; curious, what game development are you involved in? A question for anyone as well; I am preparing to host a HTTP server, with [url=http://www.webtoolkit.eu/wt]Web Toolkit[/URL] or something C++ related (maybe [URL=http://cppcms.com/wikipp/en/page/main]CppCMS[/URL]). Personally I am looking at Apache, or another UNIX-like system, but I am honestly searching for the most fundamental, down-to-earth, server to run, simplistically speaking. After this thread-find, with this momentum, any ideas or directions?
[QUOTE=Epiclulz762;36732522]My mind has been officially blown here; this is something I have been looking for. Thank you robmaister12; curious, what game development are you involved in?[/QUOTE] Right now I'm working on a wave based cooperative FPS with 2 programming buddies and an artist. Haven't posted in WAYWO in a while since we're mostly working on refactoring hacky code into something that will actually work over networking and other backend stuff. In a month or two we're hoping to have an alpha build of the game done, I'll post more about it then.
jesus christ OP how about doing some research yourself [img]http://i.imgur.com/UVXam.png[/img]
[QUOTE=Topgamer7;36729406]Read This: [url]http://gafferongames.com/networking-for-game-programmers/[/url][/QUOTE] Those articles were constructive. Thanks! And this is my final question: What are the primary differences between Tomcat and XAMPP? Tomcat is a servlet container whereas XAMPP is a web-server with some sort of regular Apache distribution. But within Tomcat's description is also says it's a web-server, so what would be the point of exactly using XAMPP?
[QUOTE=Cockman;36736468]Those articles were constructive. Thanks! And this is my final question: What are the primary differences between Tomcat and XAMPP? Tomcat is a servlet container whereas XAMPP is a web-server with some sort of regular Apache distribution. But within Tomcat's description is also says it's a web-server, so what would be the point of exactly using XAMPP?[/QUOTE] Tomcat is a JSP server, XAMPP is a package containing Apache, MySQL, PHP, and Perl.
[QUOTE=Epiclulz762;36732522]My mind has been officially blown here; this is something I have been looking for. Thank you robmaister12; curious, what game development are you involved in? A question for anyone as well; I am preparing to host a HTTP server, with [url=http://www.webtoolkit.eu/wt]Web Toolkit[/URL] or something C++ related (maybe [URL=http://cppcms.com/wikipp/en/page/main]CppCMS[/URL]). Personally I am looking at [b]Apache, or another UNIX-like system,[/b] but I am honestly searching for the most fundamental, down-to-earth, server to run, simplistically speaking. After this thread-find, with this momentum, any ideas or directions?[/QUOTE] Ok, but remember that Apache isn't an operating system.
[QUOTE=toaster468;36737771]Ok, but remember that Apache isn't an operating system.[/QUOTE] Of course; I was assuming a server system setup of Apache on UNIX, or possibly other combinations, and that was bad communication on my part.
[QUOTE=Cockman;36736468]Tomcat is a servlet container[/QUOTE] [QUOTE=Cockman;36736468]But within Tomcat's description is also says it's a web-server[/QUOTE] A servlet container is a type of web server that handles HTTP requests by running Java programs called servlets. (And JSP pages are really just servlets in disguise.) A web server is any program that responds to HTTP requests. Apache and Tomcat are both web servers, but they differ greatly in how they're configured, and in the languages you use for writing dynamic pages. With Tomcat you'd use Java or JSP; with Apache you'd typically use PHP, or maybe Python, though there are other options. XAMPP is just a convenient way to install several programs that are often used together. Don't think of it as "using XAMPP", think of it as using PHP and Apache (for example). Whether you install PHP and Apache individually, or install them using XAMPP, doesn't really matter much. [editline]12th July 2012[/editline] BTW, talking about "Apache" and "Tomcat" as separate things in the same conversation may be a little confusing, because Tomcat is an Apache project too. The [url=https://www.apache.org/]Apache Software Foundation[/url] is an organization that develops lots of software, including both the [url=https://httpd.apache.org/]Apache HTTP Server[/url] (which is often just called "Apache"), and [url=https://tomcat.apache.org/]Apache Tomcat[/url] (which is [i]also[/i] an HTTP server, but a completely different one).
Sorry, you need to Log In to post a reply to this thread.