Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 31st, 2002, 04:23 PM
irm_lexx's Avatar
irm_lexx irm_lexx is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 232 irm_lexx User rank is Private First Class (20 - 50 Reputation Level)irm_lexx User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 15 h 8 m 10 sec
Reputation Power: 7
SecurityExeptionEx?

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
Code:
        try
        {
            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));
            o.writeUTF (nameInput);
            o.flush ();
            Outputs.appendText ("Connection established...\n");
        }
        catch (IOException ex)
        {
            ex.printStackTrace ();
        }


and this is server code
Code:
ServerSocket server = new ServerSocket(port);
                while (true)
                {
                        Socket client = server.accept();
                        System.out.println("Accepted from " + client.getInetAddress());
                        
                        handler c = new handler(client);
                        
                        c.start();
                        System.out.println("Users connected: " + String.valueOf(c.handlers.size()+1));

                        
                }

When I execute client.java in editor it connects and works fine but when I open client.html it gives that error
Why does that happen and how to fix it?
__________________
Thank you for any help.

Reply With Quote
  #2  
Old January 1st, 2003, 10:02 AM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > SecurityExeptionEx?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway