December 31st, 2002, 04:23 PM
I am making a java chat and I get
securityExeptionEx:cannot access ip : port
ip and port are my ip and port
here is code to connect client to the server
and this is server code
socket = new Socket (host, Integer.parseInt (port));
InputStream ii = socket.getInputStream ();
OutputStream oo = socket.getOutputStream ();
i = new DataInputStream (new BufferedInputStream (ii));
o = new DataOutputStream (new BufferedOutputStream (oo));
Outputs.appendText ("Connection established...\n");
catch (IOException ex)
When I execute client.java in editor it connects and works fine but when I open client.html it gives that error
ServerSocket server = new ServerSocket(port);
Socket client = server.accept();
System.out.println("Accepted from " + client.getInetAddress());
handler c = new handler(client);
System.out.println("Users connected: " + String.valueOf(c.handlers.size()+1));
Why does that happen and how to fix it?
Thank you for any help.
January 1st, 2003, 10:02 AM
I assume you are trying to make an applet that does this? If so, applets can only connect to the "server" they were served from. I also further assume that you are not running an actual web server off your machine and are merely double clicking the html file to view it? I do not know what info the applet will have as its originating server when you just double click on it. This is probably the problem.
If this is all true, as long as your server (the serversocket code) and the web server that serves your applet up are on the same box when deployed, my guess is that your code will work. If you do not have a web server handy, download apache and install it. They have a binary for windows that you can install fairly quickly. You should then be able to access the html file through a running apache on your machine and run the serversocket code and I bet it will work.
Hope that all made sense and it helps. gl