Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:22+00:00 2026-05-28T07:32:22+00:00

Suppose the requirement for the TCP server that it is connected to a single

  • 0

Suppose the requirement for the TCP server that it is connected to a single client and it writes and reads serialized complete objects. The frequency of reading and writing is high. Given the requirement what are the advantages porting code from java IO to java NIO ?

Current code is something like this.. A dedicated thread for reading object from the socket and a dedicated thread for writing object to the socket. There is a single object input/output stream to which the objects is being written/read.

// Reading from socket 
private SomeObject readObject() throws IOException, ClassNotFoundException {
    Object object = oiStream.readObject();
    if (object != null && object instanceof SomeObject) {
        SomeObject someObject = (SomeObject) object;
        return someObject;
    }
    return null;
}

    // Writing to socket 
    public void writeToSocket(SomeObject someObject) throws IOException {
    if (isSocketOpen()) {
        ooStream.writeObject(someObject);
        ooStream.flush();
    } 
}

What would be NIO equivalent and its advantages given the fact that only one client will connect the server. Please do not discuss Channels/Selectors/Buffers instead compare the two library for a given requirement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:32:23+00:00Added an answer on May 28, 2026 at 7:32 am

    Object Serialization is so much more expensive than the difference between IO and NIO that you are unlikely to notice the difference. esp as Serialization is designed to work with IO.

    If you want to improve speed I suggest you try optimising the serialization.

    http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking

    http://vanillajava.blogspot.com/2011/10/serialization-using-bytebuffer-and.html

    If serialization were not an issue you can transfer data faster with blocking NIO than blocking IO.

    http://vanillajava.blogspot.com/2010/07/java-nio-is-faster-than-java-io-for.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I'm given the requirement to generate a few pages that have tables on
Suppose I have such requirement: The objects in the system all derive from a
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have requirement where I have Shape which contains area as only operation.
Suppose, I am about to start a project using ASP.NET and SQL Server 2005.
Suppose I have a custom collection class that provides some internal thread synchronization. For
Suppose that one has some lock based code like the following where mutexes are
I have a requirement that a Map will be constructed with up to 50~200

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.