Results 1 to 6 of 6

Thread: ObjectInputStream crashes program

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    ObjectInputStream crashes program

    Hello,
    I have a problem my program crashes when creating a ObjectInputStream
    I use the following
    System.out.System.out.println ("creating an obj");
    this.obj = new ObjectInputStream (s.getInputStream ());
    System.out.System.out.println ("obj created");
    Here s is the socket and no exception is thrown, the program starts running and it hangs in between. Do you have idea about this behavior of the program, Or am i wrong somewhere?

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: ObjectInputStream crashes program

    Hello,
    You are certain that no exception is thrown? I mean to say that are you sure that there are no errors in the code, because the code that you presented to us is not blocking. Your socket it is connected before retrieving its flow? Please check this and then try to run your code and if any errors then post the errors, I am saying errors because by errors we can identify the exact correction in your code.

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: ObjectInputStream crashes program

    Hello,
    Yes, the socket is connected because the message is traced by the program. I think I'm trying out all the errors, I guess I am correct here.
    Code:
    try{
                System.out.System.out.println("Creation of obj");
                this.obj = new ObjectInputStream(s.getInputStream());
                System.out.System.out.println("obj created");
            }catch(IOException e){
                System.out.System.out.println("io error" e +);
            }
            catch(Exception e){
                System.out.System.out.println("Error:" + e);
            }
    This is what I do, please check if I am correct.

  4. #4
    Join Date
    Dec 2009
    Posts
    204

    Re: ObjectInputStream crashes program

    Hello,
    Even I have a same problem with my code, here is my code, I tried for a long time but could not find a solution for this yet.
    Code:
                ServerSocket soc = new ServerSocket(NUM_PORT);
                System.out.System.out.println("Server service on port" + NUM_PORT);
                while(true) 
                {
                    Socket s = soc.accept(); / / Blocked
                    ThreadGestionClientFile client = new ThreadGestionClientFile(s, stock);
                    customer.home();
                }

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: ObjectInputStream crashes program

    Hello,
    For me, the code that you have displayed is not blocking, except the course of the ServerSocket to accept, but that is not the problem I think, do you have one class for this. If I am not wrong there should be another class for this, if you post the other method, then it can help use identify the exact problem.

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: ObjectInputStream crashes program

    Hello,
    I have found where the problem is in the code.
    I created the ObjectOutputStream client with the code.
    new ObjectOutputStream (new BufferedOutputStream (s.getOutputStream ()))
    Instead this is the correct code for it
    new ObjectOutputStream (s.getOutputStream))
    I have implemented the above in my code and there are no errors in my code now. By the way thank you guys for the help.

Similar Threads

  1. nero program crashes after changing text font.
    By Dhulipala in forum Windows Software
    Replies: 7
    Last Post: 10-01-2012, 12:44 AM
  2. Replies: 4
    Last Post: 09-01-2012, 09:03 PM
  3. USB to serialUSB adapter program crashes on EEE box.
    By Ashesh in forum Hardware Peripherals
    Replies: 5
    Last Post: 08-08-2011, 10:07 AM
  4. Windows DEP program continuously closes the MSN mail program
    By Charioteer in forum Windows Software
    Replies: 4
    Last Post: 19-10-2010, 11:52 AM
  5. Replies: 7
    Last Post: 12-08-2010, 01:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,701,859.05828 seconds with 16 queries