Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Networking A Game With More Than Two People?
beeseven
post May 8 2006, 10:19 PM
Post #1


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



In Java, it's pretty easy to set up a connection between two people, but I've been thinking about how best to connect more than two. If you only have a small number of people, and you know about what that number will be beforehand, you could have a direct connection from every person to every other person. However, if you have a lot of people or you don't know how many there will be, it's kind of difficult. Here are some things I've thought of, comments/suggestions/ideas would be appreciated:
  • Have each person store a list of connections and iterate over the list when you need to send/receive data.
    • Pros: Easier to implement
    • Cons: Might eat up bandwidth if the clients don't have much
  • Have each person only have a connection to the server which stores connections to everyone. When the server receives data from one connection, send it to all the others.
    • Pros: If the server has a lot of bandwidth, it wouldn't put strain on the clients
    • Cons: Harder to implement, lots of threads needed if connections don't send data in any order
Go to the top of the page
 
+Quote Post
uiop
post May 9 2006, 01:56 AM
Post #2


Premium Member
********

Group: Members
Posts: 192
Joined: 20-December 05
Member No.: 15,962



I don't know much about Java programming but both of those sound like good ideas. I am a proficient Visual Basic programmer and know about computer structure however so maybe I can help a bit.

I think that you should either go with the first one or do a modified "BitTorent approach". Why not set it up so that there is a central server that anyone wishing to play the game connects to. That server then winsocks them a list of IPs playing the game. If you spent enough time on it I'm sure that you could fiqure out a way so that all the computers communicated with each other, but have some communicate with more than one depending on the machine's bandwidth.

I'm not sure if this would work but you could also try working in a "ring". You could try grouping the computers in say groups of five. Then designate a "lead" computer that serves the data to the group and fetchs it from a central server.

I hope that my ideas help and that you figure it out! PM me with how you decide to do it and the results, I'd like to make a online game as well.
Go to the top of the page
 
+Quote Post
kl223
post May 9 2006, 07:59 PM
Post #3


Newbie
*

Group: Members
Posts: 5
Joined: 8-May 06
Member No.: 23,256



Hi!

At first, sorry for my english. smile.gif I'm doing my best to show you some things.

These two concepts are the decentralized and centralized network plans. rolleyes.gif

I've implemented server/client applications with both concepts, and I can say the decentralized one is more difficult.
On google you can find some text to read under the keyword: "graph theory".

At first, with it, every client needs an opened port. Only then are other clients able to connect.
Then, it's truly hard to develop the network so that every client gets every line of data. Think of it: there is basically a graph: the network of the connected clients. (The nodes are the clients themselves, of course and the lines are the connections beetween them.) How can you find a path for the information that arrives by every client AND avoids circuits.

Of course it is not possible to connect every client to every other clients. It would mean too many connections. And also would mean lotsa slow clients.

Besides, it eats up much more bandwith, because you (as a client) might need to forward someone else's data, too. (in case you don't connect to every other clients) Look at that graph:


CODE
A -- +    +-----D
       \  /
        C
       /  \
B -- +   + -----E


Here are there 5 clients. They connect through the C client. In other words, C is the gateway. All the data A, B, D and E are sending to each other is going through C.
Would you like to be the C client? blink.gif

And there are more such problems you have to think of. It can more easliy be done with small networks. That's why I think the most powerful solution is like with Direct Connect or IRC.
There are servers which can be connected to each other in a quite small network. (not 1000000 users connect to each other, just 10-15 servers)

Summa summarum: such a network shouldn't be developed without the needed knowledge.

The second plan sounds more valuable.
I suggest you should use async sockets for the server, so you don't have to use many threads in the server. Basically, the socket sends a signal when it has incoming data, you don't have to check it explicitly. You can take a look at it in the java.nio package.

kl223

This post has been edited by kl223: May 9 2006, 08:02 PM
Go to the top of the page
 
+Quote Post
beeseven
post May 11 2006, 10:49 PM
Post #4


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



What I would be using this for immediately is just a game, so it would be fine if each client sent to everyone and then received from everyone. I tried to make a chat but there were too many Threads and it got confusing. I thought about having a separate server program but realized that I don't really have a reliable server that could do that. For now, unless I have a stroke of genius, my game will remain two-player only, but I'll check out java.nio.
Go to the top of the page
 
+Quote Post
dazappa
post May 12 2006, 09:04 PM
Post #5


Newbie [Level 3]
***

Group: Members
Posts: 47
Joined: 7-May 06
Member No.: 23,184



First of all make a multi-threaded server. Then for each connecting player throw a new thread. Also you can make the client send "codes" to the server when an action is done. Like if keyboard left is pressed send code 1, then server sends code 1 to all of the clients to update the game. That way the client is doing all the figuring and saves badwidth.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Youtube Allowing Stupid People To Upload Video's(1)
  2. Nintendogs(4)
  3. Favorite Playstation 2 Game(32)
  4. Play First Ever Interactive Game On Youtube(3)
  5. Free Video Game(0)
  6. Ultimate Pvp Rpg - My Review On Monsters Game(0)
  7. Need For Speed Poll(8)
  8. Rate The Sig Above You(143)
  9. What Kids Game Sites Do You Play On?(10)
  10. What Do I Do?(2)
  11. Prism - Light The Way(1)
  12. Age Of Empires The Conquerers On Hamachi(5)
  13. My Experience With World Of Warcraft.(5)
  14. Worst Game Of All Time(64)
  15. Online Video Game Competition360,ps3,wii And Clansite(1)
  1. Hurricane Ike(8)
  2. Animal Cruelty(21)
  3. What's Your Fav Adventure Game?(29)
  4. Get Paid For People Viewing Your Images(44)
  5. Deny Or Grant Users Access To Files Of Choice (vista)(3)
  6. Good Rpg Game Besides Final Fantasy(12)
  7. Balloon Duel - Flash Game(2)
  8. Awesome Mmorpg Game(1)
  9. Best Racing Game For Pc(18)
  10. Gunz Online(35)
  11. Your Favourite Game(20)
  12. Talk About Favorite Online Games(32)
  13. The Best Multiplayer Game(66)
  14. [idea] A New Open Source Racing Game(1)
  15. Nice Models And Free Models, New Site!(3)


 



- Lo-Fi Version Time is now: 13th October 2008 - 06:52 AM