JAVA gurus help PLEASE!!!

Discussion in 'OT Technology' started by babygodzilla, May 16, 2005.

  1. babygodzilla

    babygodzilla I love rice

    Joined:
    Nov 5, 2001
    Messages:
    3,108
    Likes Received:
    0
    this is an IM program tutorial, but it's not working... here's where it starts:

    Code:
    public InstantMessageDialog(Frame owner, String recipient, String sender) 
    throws IOException
    	{
    
    ...
    //Create a new connection to server, and new user thread
    Socket socket = new Socket("localhost", 5555);
    [b]Participant user = new Participant(recipient, socket.getInputStream());[/b]
    		user.start();
    	}
    

    in Participant():

    Code:
    
    public Participant(String username, InputStream source) throws IOException
    {
    	this.username = username;
    	[b]in = new ObjectInputStream(source);[/b]
    	System.out.println("done");
    }
    
    "in = new ObjectInputStream(source);" is where the program always gets stuck. "Done" is never printed. It just gets stuck there, nothing happens, no output, no stack trace, nothing. the prog just simply stops. i have no idea what's going on... if anyone can gimme some hints that'd be great!

    THANKS!

    btw this code is supposed to be the "solutions" code to this tutorial. im using this code since i couldnt get mine to work for the same reason. this is the instruction on the tutorial

    is that the correct code?
     
  2. aphoric

    aphoric Even if god did exist, it would be necessary to ab

    Joined:
    Aug 29, 2003
    Messages:
    918
    Likes Received:
    0
    Location:
    Leaving Afghanistan
    Post the rest of the code, or link it. I am thinking a socket is doing a blocking read and it will not execute until data is available on the stream, but I can't be sure unless you post more code.
     

Share This Page