Results 1 to 8 of 8
- 05-28-2010, 09:16 AM #1
Member
- Join Date
- May 2010
- Posts
- 15
- Rep Power
- 0
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:
forget the system.out part...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());
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
- 05-28-2010, 09:23 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
UnKnownHostException means the host was, well, unknown. Can you ping that host? Telnet the port?
- 05-28-2010, 09:31 AM #3
Member
- Join Date
- May 2010
- Posts
- 15
- Rep Power
- 0
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..
- 05-28-2010, 09:35 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 05-28-2010, 09:40 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What? I incorrectly predicted an UKHE correctly?
- 05-28-2010, 09:52 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
You must be psychic.
Quick, get in touch with the James Randi Foundation and claim your million dollars*!
* Terms and conditions apply...:)
- 05-28-2010, 09:58 AM #7
Member
- Join Date
- May 2010
- Posts
- 15
- Rep Power
- 0
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..
- 05-28-2010, 11:13 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
socket connection in an applet
By j2me64 in forum Java AppletsReplies: 5Last Post: 04-12-2010, 08:34 PM -
Socket Connection problem
By xpan in forum NetworkingReplies: 4Last Post: 02-14-2010, 04:32 PM -
Unreported exception java.sql.SQLException
By javamula in forum AWT / SwingReplies: 4Last Post: 09-29-2009, 02:32 PM -
unreported exception IOException -- Yet I AM catching it?
By Agathorn in forum New To JavaReplies: 2Last Post: 09-18-2009, 11:22 PM -
Error: unreported exception java.io.IOException; ??
By jonsamwell in forum New To JavaReplies: 5Last Post: 08-24-2008, 04:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks