[java] Another networking question

Started by
1 comment, last by eedok 17 years, 5 months ago
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
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.*;
awesome

This topic is closed to new replies.

Advertisement