Jump to content
  • Advertisement
Sign in to follow this  
eedok

[java] Another networking question

This topic is 4407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This one is more of a question of effeciency than anything, in the java tutorial's client/server example they use a BufferedReader to read the incoming data, now my plan is to implement a protocol where the first byte will identify what kind of object is incoming, and the rest of the packet is to be the incoming object. So the logic would be calling read() of the BufferedReader to get the first byte then a conditional read(,,) based on the first byte. Would this be feasible or is there a more effecient way? On a side note is it possible to have the BufferedReader's read method with the 3 arguments take an object for the first argument rather than a char array? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Since you're concerned with efficiency, I think a mention of Java NIO is in order. I haven't done any networking in Java myself yet, but I've often seen asynchroneous IO being recommended for this with the argument of it being a more efficient approach. If you want to look into it, section 9 of the following document has a brief introduction to networking with java.nio.*;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!