Results 1 to 8 of 8
  1. #1
    Symbiot is offline Member
    Join Date
    May 2010
    Posts
    15
    Rep Power
    0

    Default unreported exception (socket connection)

    Hi

    I am trying to create an applet connecting to a local unit, but am stuck..

    the code giving me problems is:

    Java Code:
     public void start()
    
        {
        while (true)
            {
        
        try
               { 
            Socket clientSocket = new Socket("192.168.2.38",876);  
            DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());  
            BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));    
            outToServer.writeBytes("<d");
            sentence = inFromServer.readLine();
            clientSocket.close();
        }catch (ConnectException e)
                {
            System.out.println(e.getMessage());
    forget the system.out part...

    something is wrong and I think it's because something is missing.. but what?

    the error report I am getting is:

    unreported exception java.net.unknownhostexception; must be caught or declared to be thrown

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    UnKnownHostException means the host was, well, unknown. Can you ping that host? Telnet the port?

  3. #3
    Symbiot is offline Member
    Join Date
    May 2010
    Posts
    15
    Rep Power
    0

    Default

    hi

    yes, I can.. I fixed it.. I think by using IOException instead..

    but now I just get a 'Connection refused' and I don't know how to get access..

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    That (the first problem) was a compilation error, not a runtime error.

    This new one...well, do as asked by r035198x and try and ping the host.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What? I incorrectly predicted an UKHE correctly?

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    You must be psychic.
    Quick, get in touch with the James Randi Foundation and claim your million dollars*!

    * Terms and conditions apply...:)

  7. #7
    Symbiot is offline Member
    Join Date
    May 2010
    Posts
    15
    Rep Power
    0

    Default

    hehe, well yaah...

    I can easily ping the host, and the code I've created works fine as a normal class.
    but I need it converted to an applet.. and apparently I've run in to security issues..

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,945
    Rep Power
    19

    Default

    Well, applets do have security issues, and for good reason.
    I would have expected a different exception if it was the applet security causing the trouble.
    There are others who know more about applet pitfalls than I round here, though.

Similar Threads

  1. socket connection in an applet
    By j2me64 in forum Java Applets
    Replies: 5
    Last Post: 04-12-2010, 08:34 PM
  2. Socket Connection problem
    By xpan in forum Networking
    Replies: 4
    Last Post: 02-14-2010, 04:32 PM
  3. Unreported exception java.sql.SQLException
    By javamula in forum AWT / Swing
    Replies: 4
    Last Post: 09-29-2009, 02:32 PM
  4. Replies: 2
    Last Post: 09-18-2009, 11:22 PM
  5. Error: unreported exception java.io.IOException; ??
    By jonsamwell in forum New To Java
    Replies: 5
    Last Post: 08-24-2008, 04:11 AM

Posting Permissions

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