CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 1999
    Posts
    4

    socket connection



    Hi,


    I have written a client server chat type application. I run my server side on a different machine and connect to the server using its IP address in the call:


    sock = new Socket(serverIpAddress, port);


    When I run my client side from my IDE (Visual Age), I can connect to the server using this method. However if I use the appletviewer that comes with JDK1.2 to run my client side, it returns an error when I try to connect to the server's socket. I get a message:


    java.security.AccessControlException: access denied (java.net.SocketPermission ...


    Any ideas why this is and how to resolve the problem?


    Thanks,

    Mich




  2. #2
    Join Date
    Apr 1999
    Posts
    6

    Re: socket connection



    Hi Mich,

    Can you tell me whether you have any fire wall kind of thing or mailserver

    on the same lan.

    If so you will have the problem because firewall does allow socket connections

    to be opened through itself.

    You can try the application on a stand alone machine,it will work fine.

    You can also test the application on network but without having anykind of

    proxy etc on it.

    Regards

    Ravi

  3. #3
    Join Date
    Mar 1999
    Posts
    4

    Re: socket connection



    Thanks for the response Ravi. Here is a little more info about what is happening:


    the connection I am making to the server side is just over the network within our building here. It doesn't pass through the firewall that is between our network and the "outside world". There is a mail server on our network here but my socket connection is only being established from my computer to a computer that is beside me and on the same network. I don't interact with the mail server or firewall at all.


    The strange thing is that when I run my client from the IDE (Visual Age) I can connect just fine. But when I run my client from JDK1.2's appletviewer, I get the security error mentionned in my original post. Does the IDE act as some kind of proxy? The IDE's "appletviewer" must be doing some kind of security "autentication" that the JDK's appletviewer is not.


    Now here's another strange thing.

    I tried using the JDK to run both my server and client side from my own computer. I start my server (it is an application, not an applet), and then I start my client side using JDK1.2's appletviewer. In this case I can connect to the server but when my client user disconnects (closes the client window)the server throws an exception with the following message:


    Error: java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read

    Error getting in-out streams from socket.


    The server is using the readLine() method on a BufferedReader object created using the socket from that client. Usually the readLine()method returns null when the client closes it's side but apparently when running it with the JDK's appletviewer I get a SocketException.


    Sorry about this long post but I am out of ideas and am hoping you or someone else can help me with this problem.


    Let me know if anyone can help.


    Thanks,

    Mich



  4. #4
    Join Date
    Mar 1999
    Posts
    22

    Re: Check the port number?



    Hi.


    If you create Socket program - Cleint and Server program,

    this program use port number of your defined number.

    However, if you use applet, I think that socket must use HTTP port 80.

    This must be problem.

    Try server port as 80 also.

    But I'm not sure.


    Hope for help.

    -Masaaki Onishi-

  5. #5
    Join Date
    Apr 1999
    Posts
    4

    Re: socket connection

    Applet security states that the applet cannot open a socket connection to any machine other than the machine from which it originates. What does this mean?
    This means that if I sent a HTTP request to mymachine.com, and the page it returns contains an applet, that applet runs on my local machine (The machine wit the browser), and the applet is only allowed to open a socket connection back to mymachine.com. You will find the appletviewer adheres tot his just like MSIE and Netscape. When you run it from an IDE, however, the IDE is not using the appletviewer (more than likely), but executing it as an actual Application, which has no such security restrictions.
    Hope this helps.



  6. #6
    Join Date
    May 2000
    Location
    Ireland, Dublin
    Posts
    1

    Re: socket connection

    For days I had the same problem reported by Mich, then I read the reply from Ravi, so I decided to try what Ravi suggested: test the application in a standalone machine (not behind a proxy server or any sort of thing). So I did it and guess what ? It worked perfectly. Now my question is:
    Is there a way to tell java environment that when access the internet use a proxy server ? Then I found out that Yes, there is a way:

    System.getProperties().put( "proxySet", "true" );
    System.getProperties().put( "proxyHost", "your proxy host");
    System.getProperties().put( "proxyPort", your proxy host port);

    So hopefully this can be helpfull to anybody having the same problem.....

    Thanks to Mich and Ravi for sharing their knowlodge.

    Good luck

    Jose


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured