Can't open socket to localhost

Discussion in 'Java' started by Mark McKay, Aug 21, 2003.

  1. Mark McKay

    Mark McKay Guest

    I'm trying to set up a simple client/server pair of programs using
    sockets, but am finding I can't establish a connection to the server
    running on my localhost. When I execute:

    InetAddress[] ia = InetAddress.getAllByName("localhost");
    Socket sock = new Socket(ia[0], 8185);

    I receive:

    java.security.AccessControlException: access denied
    (java.net.SocketPermission 127.0.0.1:8185 connect,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
    at java.security.AccessController.checkPermission(AccessController.java:401)

    What can I do to test my programs?

    Mark McKay
    --
    http://www.kitfox.com
    Mark McKay, Aug 21, 2003
    #1
    1. Advertising

  2. Mark McKay

    winbatch Guest

    Check your java.security file and make sure to give yourself the correct
    permissions for socket connections.

    "Mark McKay" <> wrote in message
    news:...
    > I'm trying to set up a simple client/server pair of programs using
    > sockets, but am finding I can't establish a connection to the server
    > running on my localhost. When I execute:
    >
    > InetAddress[] ia = InetAddress.getAllByName("localhost");
    > Socket sock = new Socket(ia[0], 8185);
    >
    > I receive:
    >
    > java.security.AccessControlException: access denied
    > (java.net.SocketPermission 127.0.0.1:8185 connect,resolve)
    > at

    java.security.AccessControlContext.checkPermission(AccessControlContext.java
    :269)
    > at

    java.security.AccessController.checkPermission(AccessController.java:401)
    >
    > What can I do to test my programs?
    >
    > Mark McKay
    > --
    > http://www.kitfox.com
    winbatch, Aug 21, 2003
    #2
    1. Advertising

  3. (Mark McKay) writes:

    > java.security.AccessControlException: access denied
    > (java.net.SocketPermission 127.0.0.1:8185 connect,resolve)


    Do you use an applet loaded from another machine than localhost?
    Tor Iver Wilhelmsen, Aug 21, 2003
    #3
  4. Mark McKay

    Mark McKay Guest

    Tor Iver Wilhelmsen <> wrote in message news:<>...
    > (Mark McKay) writes:
    >
    > > java.security.AccessControlException: access denied
    > > (java.net.SocketPermission 127.0.0.1:8185 connect,resolve)

    >
    > Do you use an applet loaded from another machine than localhost?


    No, they're both running on localhost. Eventually I'd like to have my
    server running on a remote machine and my web applet to be downloaded
    from that machine and connect back to the server. Is there a way to
    do this without requiring my users to modify java.security?

    Mark McKay
    --
    http://www.kitfox.com
    Mark McKay, Aug 22, 2003
    #4
  5. Mark McKay wrote:
    > Tor Iver Wilhelmsen <> wrote in message news:<>...
    >
    >> (Mark McKay) writes:
    >>
    >>
    >>>java.security.AccessControlException: access denied
    >>>(java.net.SocketPermission 127.0.0.1:8185 connect,resolve)

    >>
    >>Do you use an applet loaded from another machine than localhost?

    >
    >
    > No, they're both running on localhost. Eventually I'd like to have my
    > server running on a remote machine and my web applet to be downloaded
    > from that machine and connect back to the server. Is there a way to
    > do this without requiring my users to modify java.security?


    The server from which the applet is loaded is the _only_ system to which
    it can make a network connection without modification of the client's
    security policy. It is possible that that is in fact related to the
    problem you are experiencing -- normally applets are forbidden from
    accessing most resources on the client machine, so it may be that your
    VM is applying that restriction without noticing that the applet came
    from the same machine.


    John Bollinger
    John C. Bollinger, Aug 22, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jiong Feng
    Replies:
    0
    Views:
    819
    Jiong Feng
    Nov 19, 2003
  2. Alex
    Replies:
    4
    Views:
    566
    Hasani Blackwell
    Feb 8, 2005
  3. =?Utf-8?B?S2VuTGVl?=
    Replies:
    5
    Views:
    2,708
  4. EdwardH

    Localhost isn't localhost

    EdwardH, Sep 29, 2005, in forum: Java
    Replies:
    20
    Views:
    6,386
    Roedy Green
    Oct 1, 2005
  5. koicat
    Replies:
    0
    Views:
    224
    koicat
    Jul 2, 2010
Loading...

Share This Page