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

  • Home
  • SEARCH
  • 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 7399427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:33+00:00 2026-05-29T04:03:33+00:00

Client code: try { Socket socket = new Socket(ip, port); OutputStream output = socket.getOutputStream();

  • 0

Client code:

try {
            Socket socket = new Socket(ip, port);
            OutputStream output = socket.getOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(output);
            InputStream input = socket.getInputStream();
            ObjectInputStream in = new ObjectInputStream(input);
            out.writeByte(1);
            FileHandler fh = (FileHandler) in.readObject();
            //processing stuff
            out.flush();
            out.close();
            output.flush();
            output.close();
            input.close();
            in.close();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

Server code:

        try {
            ServerSocket server = new ServerSocket(port);
            Socket socket = server.accept();
            InputStream input = socket.getInputStream();
            ObjectInputStream in = new ObjectInputStream(input);
            int type = in.readByte();
            //processing stuff (which includes closing the streams and sending FileHandler object)
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

The server never receives the byte. It just waits for the byte from the client, and it never comes. I’m not sure why it isn’t sending, or getting received. Any help is much appreciated.

  • 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-29T04:03:34+00:00Added an answer on May 29, 2026 at 4:03 am

    If I had to make a guess it’s because in your client you block on in.readObject(); waiting for the server to send you something thus never flush the output stream thus … nothing ever gets sent.

    Move your read to after you flush your output stream.

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

Sidebar

Related Questions

Client code is pretty simple: <form action=DDServlet method=post> <input type=text name=customerText> <select id=customer> <option
I have a very simple client server code written java(server listens on some port
I am using an ObjectInputStream and ObjectOutputStream for my client to talk to a
I have some cross platform DNS client code that I use for doing end
After trying to understand why client code is not rendered in a page (injected
I have a year's experience writing client code but none with server stuff. I
I put a TCP server and client code in PIC controller. Now just wanted
Say I have a simple client/server scenario with one method: // client code $client
I have an ASP.NET MVC server app and client code which uses jquery. I'd
I deployed a JAX-WS Service and use wsimport to generate client code. Because I

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.