Results 1 to 2 of 2
  1. #1
    dredd is offline Member
    Join Date
    Mar 2013
    Posts
    11
    Rep Power
    0

    Default Problem with EOFException and ObjectInputStream object

    I've got 2 problems:
    1. why when I'm sending EnterMyGuiChat object the _iObject doesn't know it's EnterMyGuiChat object (I'm getting null in _iObject) and i'm getting the message: EOFException
    2. I'm getting EOFException when I'm sending from the server side a String that _iObject recognize it as a string.
    Here is my code:

    public void RunClient() throws EOFException{
    Socket _iSocket=null;
    try{
    _iSocket=new Socket(_mServerName,_mServerPortName);
    _mObjectInputStream=new ObjectInputStream(_iSocket.getInputStream());
    _mObjectOutputStream=new ObjectOutputStream(_iSocket.getOutputStream());

    _iIsLogged=true;
    while(_iIsLogged){
    Object _iObject=null;
    _iObject=_mObjectInputStream.readObject();
    if(_iObject!=null){
    // Get a reference to the GUI
    if(_iObject instanceof EnterMyGuiChat){
    _iObject=new EnterMyGuiChat();
    _mClientGui=(EnterMyGuiChat)_iObject;
    }

    if(_iObject instanceof String){
    String g="asd";
    }
    }

    ((ObjectOutput) _mObjectOutputStream).flush();
    }
    }catch(IOException e){
    e.printStackTrace();
    }catch (ClassNotFoundException e) {
    e.printStackTrace();
    }finally{
    try{
    if(_mObjectInputStream!=null){
    _mObjectInputStream.close();
    }
    if(_mObjectOutputStream!=null){
    _mObjectOutputStream.close();
    }
    }catch(IOException e){
    e.printStackTrace();
    }
    if(_iSocket!=null)
    try{
    _iSocket.close();
    }catch(IOException e){
    e.printStackTrace();
    }
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Problem with EOFException and ObjectInputStream object

    Please wrap your code in
    Java Code:
     tags
    so it retains its formatting.
    If you are getting an Exception, please post the full exception and stack trace.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. ObjectInputStream not reading my object via networking
    By L19htn1n9 in forum Advanced Java
    Replies: 6
    Last Post: 06-27-2012, 11:02 AM
  2. Replies: 1
    Last Post: 11-05-2011, 09:39 AM
  3. Problem With ObjectInputStream
    By shomid in forum Networking
    Replies: 1
    Last Post: 08-29-2011, 04:12 PM
  4. EOFException error in I/O. Are threads the problem?
    By JavaVox in forum Threads and Synchronization
    Replies: 5
    Last Post: 06-24-2011, 07:53 PM
  5. Object Input Stream EOFException
    By FlyNn in forum New To Java
    Replies: 1
    Last Post: 12-18-2010, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •