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 6790859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:46:35+00:00 2026-05-26T17:46:35+00:00

Using Input/Output stream to pass objects between my client and server. I can both

  • 0

Using Input/Output stream to pass objects between my client and server. I can both send and receive objects with my server, and and now i want the same for the client which as of now only can send. So i gave my client an ObjectInputStream. However, when i initilazie it, it blocks! Been searching around and found answers but no solution.

Please help!

public GameConnection(String strPort, TextArea chat)
    {
        this.port = Integer.parseInt(strPort);
        System.out.println("GameConnection::Constructor(): Connecting on port " + port);
        this.chat = chat;


        connect = new Connection();
        sendObject();
    }
    public void sendObject()
    {
        try
        {  
            obj_stream.writeObject(new String("GameServer received a message!"));  
        }
        catch(Exception e){System.out.println("GameConnection::sendObject(): " + e);}  
    }  

    protected class Connection extends Thread
    {
        private boolean alive = true;

        public Connection()
        {
            try
            {
                socket = new Socket(host, port);
                System.out.println("Connected to GAMESERVER" + host + " on port + " + port);
                obj_stream = new ObjectOutputStream(socket.getOutputStream());
                // Next line BLOCKS!!!
                //ObjectInputStream stream = new ObjectInputStream(socket.getInputStream());
            }
            catch (IOException ioe)
            {
                System.out.println("Connection::constructor() " + ioe);
                Terminate();
            }
            catch (NullPointerException npe)
            {
                System.out.println("Connection::constructor() " + npe);;
                Terminate();
            }

        }

I tried using them in different threads but it had the same problem, at least for me 🙁

  • 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-26T17:46:35+00:00Added an answer on May 26, 2026 at 5:46 pm

    yes, this question has been asked many times before. the object stream format has a header, and the ObjectInputStream reads that header on construction. therefore, it is blocking until it receives that header over the socket. assuming your client/server code looks similar, after you construct the ObjectOutputStream, flush it. this will force the header data over the wire.

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

Sidebar

Related Questions

I want to send a large amount of data to a server using NSURLConnection
I have a stream object, and I want to create and output xml using
I'm using Zend_Form to output a set group of checkboxes: <label style=white-space: nowrap;><input type=checkbox
I am having some trouble using the redirected input/output of a process. Originally, I
I am using 2 threads- ReaderThread for reading from the Socket input stream and
I've been using the '-wap-input-format' CSS property to force to numeric input using *N.
I'm reading from the standard input using the read() system call but there's a
I have some data (which users input using WYSIWYG editor). I have created a
I'm trying to sanitize/format some input using regex for a mixed latin/ideographic(chinese/japanse/korean) full text
Anyone know a good solution for filtering input using jQuery? I'd like to do

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.