Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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  
  Using java.nio SocketChannel design for games  (Read 2851 times)
0 Members and 1 Guest are viewing this topic.
Offline vydias

Senior Newbie

Welcome to my world!

« Posted 2003-01-25 17:55:38 »

I've changed all of my network communications over to the new java.nio API greatly improving network speed, memory usaged and performance by using ByteBuffer and SocketChannels and ServerSocketChannels, and the new Non-blocking i/o.  

My problem is that while ServerSocketChannel connection requests allow me to process all reads and writes without using multiple threading (big improvement), I would like to get the same improvements for those players in our game that actually start the connection with a SocketChannel.  

Say we have 20 players already logged in and they all need to communicate then the last player that logged in. I will need to create SocketChannel connections to each of those 20 players.  If this is done I don't see a way to handle the reading from these channels without implementing a threaded listener on each channel. Is there a way to pool these SocketChannels like you can the ServerSocketChannel and have one thread listening for data coming from any/all of them?

None of the examples out there seem to address this issue. Without this ability I'm only able to cut my thread usage down by half rather then simply having 1 or at most 2 threads handling TCP communications for our game. Anyone have code that accomplishes all network i/o with one thread?
Offline vydias

Senior Newbie

Welcome to my world!

« Reply #1 - Posted 2003-01-25 19:26:13 »

btw this is a p2p networking paradigm so we can't have a central server for this part of our game communications. Thus I need to handle multiple SocketChannel connections when logging into the game for communications that is non-UDP capable. Meaning if I'm In TCP mode (firewalled, router non-portforwarding) or another peer is in TCP mode, direct connections must be established from the TCP mode player to the non-TCP mode player. If both parties are in TCP mode then we use a single RELAY server (all TCP players must connect to it) because direct connections can not be made between the two TCP players.

Just a little info on our networking so that people understand why we need to scale back our thread usage and why we have to use TCP connections.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

basil_ (42 views)
2015-09-30 17:04:40

shadowstryker (21 views)
2015-09-29 15:55:06

TheSpaceHedgehog (27 views)
2015-09-29 01:58:48

GamerC4 (50 views)
2015-09-24 21:10:38

GamerC4 (70 views)
2015-09-24 21:09:48

htuy (27 views)
2015-09-24 04:57:24

htuy (35 views)
2015-09-24 04:56:35

htuy (25 views)
2015-09-24 04:56:09

htuy (26 views)
2015-09-24 04:47:33

Roquen (63 views)
2015-09-21 12:54:28
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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‑
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!