Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Best approach for networking a board game?  (Read 2203 times)
0 Members and 1 Guest are viewing this topic.
Offline theraje

Senior Newbie




If you're thinking what I'm thinking, get help.


« Posted 2005-08-06 15:34:36 »

Hey guys, it's been a while since I've stopped by. The new forums look great!

I have a question about writing a networked board game. I've been looking into doing my network code via NIO, but several problems arose, including an inability to find information on it, and hearing that it has a lot of annoying bugs. So, I figured my best bet would be to ask you guys, since you know what you're doing. Smiley

I'm writing a board game that will support 2-8 players, and will need to be able to send objects (or at least data about the object) to other players. I also need to implement a chat feature. Reliability in regards to data sent/received is an important factor. So, here are my questions:

Which is more suited to my project, NIO, or IO+Net?
Should I use TCP/IP or UDP for this project? (I'm thinking TCP will be required, but I'm not sure how it works with a P2P setup.)
Is Peer-to-peer or Client/Server the best approach? (I want people to be able to connect to other players without a need for a central server.)

Thank you for any guidance you can give me!


They say all great artists are insane. I'm not saying I'm a great artist, but I'm certain I have what it takes.
Offline cborders

Junior Member





« Reply #1 - Posted 2005-08-06 17:48:38 »

I have limited knowledge on this subject so feel free to thorw out everything I say, but...  If you need data transfer reliability then you needto use a TCP connection and I think that you would need to use a central cerver to make all of the players aware of each other.  If you didn't then each player would need to set up a P2P connection with each of the other players instead of simply connecting to the server and letting it handle all of the messy stuff!

In fact this is the set up we used to make a "BW3 / Bar style" trivia game!  Where the server gives out a question and 4 answers, then a hint is displayed every so often and the sooner you get the right answer to more points you get!
Offline theraje

Senior Newbie




If you're thinking what I'm thinking, get help.


« Reply #2 - Posted 2005-08-06 18:48:52 »

I think that you would need to use a central cerver to make all of the players aware of each other.  If you didn't then each player would need to set up a P2P connection with each of the other players instead of simply connecting to the server and letting it handle all of the messy stuff!

Are you sure I need a central server, i.e. a Web server that continuously runs a daemon thread (or whatnot) for clients to connect to?

They say all great artists are insane. I'm not saying I'm a great artist, but I'm certain I have what it takes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cborders

Junior Member





« Reply #3 - Posted 2005-08-06 19:07:15 »

We just wrote another Java application that accepted incoming connections, it wasn't to bad, but as I said my experience is pretty limited so if anyone else knows a better way, I'd like to know too!  Wink
Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2005-08-07 04:28:45 »

The big issue with P2P is how you find each other. 
If you are going to go peer to peer, the next question is, is it local LAN or Internet?  If its LAN you can use the brodcast based game discovery code I presented in Practical Java Game Programming.

If its going to be an internet game it gets a lot more complex.  If you dont mind your players entering each other's IPs and you don't have any firewall concerns then you can do without the server for an internet game, otherwise you need some kind of marshalling server out there.

Given the hig hlatency tolerances of this kind of game your choices are almost unlimited.  This is even one of those rare game types where you could do quite a reasonable server as a J2EE servlet.  Using a servlet has the advantage of using HTTP to cmmunicate, which almost everybody can get out of even the most restrictively firewalled networks.   Be aware however that there is no solution for direct peer to peer over the internet that will penetrate typical consumer firewalls without a server to at least do UDP "introducing"

What Id personally suggest for this kind of game, if your goal is internet play, is going the servlet based server route.
.   



Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2005-08-07 04:32:13 »

BTW.

Ive done a  number of NIO based projects and so far had no bug issues.

HOWEVER NIO is a lot hard to use correctly then java.net, and its pretty pointless for clients who are only going to handle a handful of open sockets at a time.  NIO is  really intended for serevs that have to handle O(100) or up connections at once.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline theraje

Senior Newbie




If you're thinking what I'm thinking, get help.


« Reply #6 - Posted 2005-08-07 18:17:05 »

Thanks for the info! Firewalls are a concern for me (since I don't need to be flooded with complaints about how the program doesn't work), so I'm thinking what I need is a client/server architecture. It also makes more sense considering the type of game, which will need a "host" of sorts. I'll do a little more reading on the advantages and disadvantages between client/server and P2P (since that info is considerably easier to find). Thanks again!  Grin

They say all great artists are insane. I'm not saying I'm a great artist, but I'm certain I have what it takes.
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-08-08 05:50:49 »

If you want to do P2P through cosnuemr firewalls (without reauiring the users to map ports on their firewall) you'll need to do what is usually called "UDP Punchthrough".  If you google on that youll find lots of explainations.  The key is that it still needs a server to act as an "introducer" that gets the session started.

Given the kind of game you are doing, if you have a host available that will run servlets for you, I'd strongly suggest that an HTTP servlet based server/client  solution will likely be the simplest solution.

Good luck!

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Matlu

Junior Member




Hasta La Victoria Siempre!


« Reply #8 - Posted 2005-08-08 19:24:40 »

I have already created exactly same games as you are planning to do (see the site in my signature)

- it has client / server architecture, it communicates through TCP
- the server is java application. But Jeff's suggestion is good. If I had to start again from scratch I would consider servlets
- at the beginning I used old java IO for both server and client, but I encountered very annoying problems, so I re-worked the server to use NIO. It works great now. The clients (applets)  still use old java IO, for clients it's ok

Multiplayer Online Games
http://www.duelboard.com
Offline crocoPuffs

Junior Newbie





« Reply #9 - Posted 2005-09-08 17:57:39 »

Using the servlet method as suggested, could you describe the communication between the servlet and the client?

And more specifically, I'm working on something like this that will likely use Flash as the client.  Is there anything I should be aware of in that case?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!