Socket connection in Applet

Hi champ,
I created an server and client chat applet. when i execute server and client application it works fine. but when i use applet for client it throws IONetPermission denied error. I know i have to do some thing in policies. But i cannot do in client machine. So is there any other way to handle. adn i know that it is possible because i have seen few chat which use socket connection and yet client has to do nothing with policy. So there must be some thing to do in server machine. Please help me to find the process that i have to follow in server machine to run this client applet without any error.
Thanks in advance.
Nischal

Security model for the applets doesn't allow you to connect to hosts other then host where you download applet code. To go through that limit you have to sign your applet code or provide a proxy on your web site hosting a applet.
The good starting point for a code signing and applet security is a http://home.istar.ca/~neutron/java.html

Similar Messages

  • Share socket connection among applets

    Hi all,
    I'm working on a web-based Instant Messanger project which use applet as
    client. User can open serveral applet (say IE window) to chat with different
    persons. I wanna client keep only one socket TCP connection with server
    regardless how many applets being opened. Rest of technical problems seems
    ok now, just as thread pooling, message recognize, etc.
    Chris Chen
    Software Engineer
    Bleum, Inc.
    [email protected]
    www.bleum.com

    Cant be done.. well maybe can be done..
    cant be done..
    because a Socket is an ip address and a port number, if a process is using a port then it is denied to another process..
    maybe can be done..
    well you could use Applet.getApplets() to get your clients to share 1 Socket (ie 1 becomes a master and the others communicate through that...) but only if they are in the same browser page/frame hierarchy, but thats not what you want is it...
    work arround...
    in the server keep a list of users rather than connections (each user may have a list of connections).
    then as a user starts a conversation the communication chanel is stored with the connection.
    im guessing that if a user has a few chats going when a person replies to that user you cant figure out which of the users client applets to send the message to...

  • Applet socket connection

    Hi,
    I have an applet that connects to a server java console program through a socket connection which works fine from the command line using appletviewer but doesn't work when running in a html page. The applet is not signed however because the applet and server are running on the same machine it shouldn't need to be. I have used socket connections in applets before and have managed to make the connection to server without having it signed but this one is not working for some reason. I have checked the port is opened and again its the same one I have used before so I know its open.
    I am getting the message java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:5000 connect,resolve) when calling:
      Socket s = new Socket(ip,port);I also have a java.policy.applet file in the project root directory which has the following in:
    grant {
      permission java.security.AllPermission;
    };Does anyone know a reason why access could be restricted?

    Night.Monkey wrote:
    Hi,
    I have an applet that connects to a server java console program through a socket connection which works fine from the command line using appletviewer but doesn't work when running in a html page. The applet is not signed however because the applet and server are running on the same machine it shouldn't need to be.Wrong. An unsigned applet can only connect back to the server from where it was downloaded. Your applet comes from www.javawebgames.co.uk and tries to connect to 127.0.0.1.
    Would your server be at www.javawebgames.co.uk there should be no problem.
    I also have a java.policy.applet file in the project root directory which has the following in:
    grant {
    permission java.security.AllPermission;
    };I think this should have zero effect when you are running in the actual browser.

  • Decompile applet and proxify all URL and socket connection and recompile

    Hi,
    Please anybody have idea for the below.
    I need to decomple the applet class file to .java file and need to change all URL and Socket connection to proxify all connections from applet. and recompile the sample applet to make ready to load in browser.
    Thi is to load the applet form the web server through one proxy server. In the proxy server side While loading the applet from web server that applet code need to be changed to modify the URL and connections used in that applet to change the further connection from applet through proxyserver.
    Compile and decompile is not a problem that i can use javac and javap respectively.
    But I want to know how to change all URL and connection in applet. is there any easy way to handle this with out changing the applet code.
    can Anybody help me.
    Thanks and Regards,
    Shiban.

    Not sure how you do that:
    Client <----[HTTPS]-----> Secure Gateway <------[HTTP]------->Web servers
    or
    Internet Explorer/Mozilla <----[HTTPS]-----> proxy <------[HTTP]-------> Google
    Is the above correct?
    If so than what are the proxy settings in IE/Moz, I can specify the proxy address in the
    browsers but not the proxy type (SSL).
    When you want to visit a page like google I gues you just type http://www.google.com in
    the browsers address bar. The browser will figure out how to connect to the proxy.
    Java has got the control panel in the general tabl there is a button "network settings...:"
    I have it to "use browser settings" and this works for me.
    All URL and URLConnections work but the sockets don't (maybe put in a bug report)
    for example games.yahoo.com -> card games -> bridge -> create table
    In the trace I can see:
    network: Connecting http://yog70.games.scd.yahoo.com/yog/y/b/us-t1.ldict with proxy=HTTP @ myproxy/00.00.00.00:80
    network: Connecting socket://yog70.games.scd.yahoo.com:11999 with proxy=DIRECT
    The second one fails because port 11999 is not open (what idiot uses an unassigned
    port for a profesional site is beyond me).
    http://www.iana.org/assignments/port-numbers
    #               11968-11999 Unassiged
    Even if the port was open on the proxy you'll notice with proxy=DIRECT that
    "use browser settings" does not work with socket (bug report??).
    Anyway my advice is to open the java console (windows control panel or javacpl.exe in
    the bin dir of java.home) and make sure it is set to "use browser settings"
    Then enable a full trace:
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    Print out the full trace of the exception:
    try{...}catch(Exception e){e.printStackTrace();}
    Then visit the games.yahoo and try to create a new table playing bridge.
    Inspect the trace and see if it works/why it doesn't work.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Applet socket connect behaves wrong.

    Hi,
    I have a very strange behavior from the Socket connect method. When i run the code attached as an applet the connect returns as if the connection is established (no machine on my network with the address 12.12.12.12 and ping to 12.12.12.12 fails as expected).
    When i run it from a command line (in a stadard main) the connect behaves as expected an i get an exception.
    Any ideas? what am i doing wrong? (or is it a known applet behavior???)
    thanks...
    ===========================================================
    the code:
    ===========================================================
    public void start() {
    SocketAddress sockaddr = new InetSocketAddress("12.12.12.12", 16000);
    Socket sock = new Socket();
    try {
    System.out.println("Start conn 1");
    sock.connect(sockaddr, 3000);
    } catch (IOException e) {
    System.out.println("Connect failed");
    e.printStackTrace();
    return;
    if (sock.isConnected()) {
    System.out.println("Connected");
    System.out.println("Connect succ 1");
    Edited by: ohad_atia on Jun 28, 2009 12:25 AM

    here is the applet start code - the rest of the methods are empty:
    (no exception here - that is the problem)
          public void start() {
              SocketAddress sockaddr = new InetSocketAddress("12.12.12.12", 16000);
                     Socket sock = new Socket();
              try {
                   System.out.println("Start conn 1");
                   sock.connect(sockaddr, 3000);
              } catch (IOException e) {
                   System.out.println("Connect failed");
                  e.printStackTrace();
                  return;
              if (sock.isConnected()) {
                 System.out.println("Connected");
              System.out.println("Connect succ 1");
          }the code and output i got when i run it using a command line:
    import java.net.Socket;
    import java.net.SocketAddress;
    import java.net.InetSocketAddress;
    import java.io.IOException;
    public class networktest {
            public static void main(String[] argv) {
                    SocketAddress sockaddr = new InetSocketAddress("12.12.12.12", 16000);
                    Socket sock = new Socket();
            try {
                    sock.connect(sockaddr, 3000);
                } catch (IOException e) {
                    System.out.println("Connect failed");
                    e.printStackTrace();
                    return;
                if (sock.isConnected()) {
                       System.out.println("Connected");
                System.out.print("Connect succ");
    }output:
    Connect failed
    java.net.SocketTimeoutException: connect timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at networktest.main(networktest.java:17)
    thanks for your help

  • Establish socket connection with local pc using Applet

    Hi,
    I want to write an applet embedded in my web application.
    When I access the web application from my PC which is connected to a RFID reader, I need the applet to make a socket connection to the attached RFID reader.
    Is this allow?
    If not, what do I need to make this possible for applet?
    Please advise.
    Thank you.

    HI Helen,
    Just to check.
    He is on XP ?
    He is using AIM 5.9 ?
    He has Tuned the camera and Mic to the App ?
    If he is at Service Pack 2 he has enabled the app through the XP firewall ?
    You have the MAc firewall Off.
    The ports are enabled in your modem.
    Either using UPnP or these actual ports
    5060, 5190, 5678, 16384-16403 for just the AIM stuff.
    Have you changed the Quicktime setting to match your download speed ?
    Can you and he get any of the people or test accounts o this page ?
    http://www.ralphjohnsuk.dsl.pipex.com/ContactTesters.html
    2:34 PM Saturday; April 8, 2006

  • Applet using socket connection always go through proxy server

    Socket connection with socks always go through proxy server
    We have two applets in different codebases using socket to talk to each other, until now nothing new, but the problem is that we are behind a proxy server with socks and because of that, the connection always go through the proxy server even with proxy override point to the applet machine. We have tried a lof of things and until now nothing worked, it looks like the socket is ignoring proxy override configuration. We would like to know if there is a way to solve this problem making the applets comunicate to each other ignoring the proxy server. It should happen when we set the plug-in option to "no proxy host", but it doesn't. Maybe it can be a bug of JVM, I don't know, just maybe, and if it's true, any other good idea would be welcome as well.
    Thanks in advance.

    Hi,
    I am not very much sure if I can help you. In my previous experience, once you set the system property to use the proxy, then the jvm uses the proxy. If you want disable, in your code, you have to disable it.
    like System.setProperty("socksProxyHost","someHost"), Properties props = System.getProperties(); props.remove(("socksProxyHost");

  • Opening a socket from an applet

    I tried to open a socket from an applet to a server on a remote computer and I've got a refusal message.
    When I try it on a server in the local machine, it works.
    What could be the problem ?
    P.S. : when I open the socket from an application in the Java environment, to the same remote server it works ok.

    this is part of the security system built into java and Applets
    unless you sign an Applet it cannot do many "dangerous" things, like..
    access the loacl file system
    connect to any server except the server that it came from

  • Socket connection access denied

    I created a class that handles all the socket level calls for my Applet class. When I'm trying to open the socket, I get an exception saying "access denied (java.net.SocketPermission 172.16.11.63:3333 connect,resolve)". When I open the socket within the Applet class, it opens fine. I would think the socket class would have permissions to the socket because it's being loaded from the same host and the same directory as the Applet. Can someone please explain this to me? Thanks.

    Normally a webserver runs on port 80. If you're connecting to port 3333, then that counts for a different host.
    Morten

  • Connecting an applet to database

    Hello Everybody,
    I have a problem of connecting the applet to the database through a separate java class.
    to be more clear i have a applet which uses a java class file for databse conenction.
    the error i'm facing while doing this is that java.net.socket permission.
    my database is oracle and i'm using thin driver to establish the connection.
    now i have the doubt that is it the right kind of approach.
    i mean can i connect the applet to the database through a normal java class.
    i hope some can get me the solution.
    thanking u in advance
    regards
    RaviTeja

    I suppose your problem is that you get a Security Exception when your applet try to open a JDBC connection to a database located on another server, right?
    To solve the problem, you have to sign your applet with a digital signature or bring the webserver and the database on the same machine.
    (Concerning the digital signatures, look in the forums, and you will find tons of messages about it)

  • Help with an exception when trying to establish a socket connection

    i am trying to make a chat (using an applet for the client).......
    it uses an simple socket connection between the server and clients.....when i connect the client to address 127.0.0.1 or localhost everything works fine, but when i try to connect the client to my DNS name or ip, i get an exception....the exception reads:
    java.security.AccessControlException: access denied (java.net.SocketPermission nextwave.dyndns.org resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
    at java.security.AccessController.checkPermission(AccessController.java:401)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
    at java.net.InetAddress.getAllByName0(InetAddress.java:937)
    at java.net.InetAddress.getAllByName0(InetAddress.java:918)
    at java.net.InetAddress.getAllByName(InetAddress.java:912)
    at java.net.InetAddress.getByName(InetAddress.java:832)
    at java.net.InetSocketAddress.<init>(InetSocketAddress.java:109)
    at java.net.Socket.<init>(Socket.java:119)
    at Client.<init>(Client.java:42)
    at ClientApplet.init(ClientApplet.java:12)
    at sun.applet.AppletPanel.run(AppletPanel.java:347)
    at java.lang.Thread.run(Thread.java:536)
    what is this all about??????
    i'm not that fluent in java, or networking at that, but i'm sure there is something i can do to fix this......
    any help would be greatley appreciated.

    this is why i am not heart-broken that i will be going the other (executable jar) route.......the major deciding factor is the people who will be using this chat will most likley not be able to edit the policy file due to lack of knowledge, and probably won't want to take the time to try.....they would rather download a program, and double-click execute........
    i thank you for taking the time to help me......i have been reading through the posts in this forum, and am seeing it is a good place to get help, so i will be sticking around.....
    mahalo and happy java

  • Is there any way to make a socket connection to a java file on the net?

    Is their anyway to make a socket connection to a java applet that I place on a webhost? I want to connect to a javaapplet from my vb.net program and send commands to it. Like http://www.geocities.com/Sylonious/javafile.jpx:7070
    ?

    Is their anyway to make a socket connection to a java
    applet that I place on a webhost? I want to connect to
    a javaapplet from my vb.net program and send commands
    to it. Like
    http://www.geocities.com/Sylonious/javafile.jpx:7070
    ?You wouldn't have a port in the url, you would need to have the socket open in the applet code. The vb.net program would also need to be on the same server as the applet or you'll have security issues and I doubt that's possible with geocities. I don't know what you would need to communicate with a vb.net if anything, but I'm sure it's possible.

  • Can a socket connection be created inside a Timeline to port 23?

    Is there a security restriction or some other reason why I always get a java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method)
    when I try to open a socket inside a function in a Timeline to port 23? The connection works fine to the host if the code is not is not inside a Timeline. It also seems that a socket connection to port 80 works okay too.
    Thanks for any help in advance.
    Regards,
    Richard

    Here is the Timeline code:
    var addr:InetSocketAddress;
    var sConn:Socket;
    var reader:BufferedReader;
    var s:String;
    Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames: [
    KeyFrame {
    time: 10s
    action: function() {
    try {
    addr = new InetSocketAddress("somehost",23);
    sConn = new Socket();
    sConn.connect(addr);
    reader = new BufferedReader(
    new InputStreamReader(sConn.getInputStream()));
    // reader.readLine(); // throw away first line
    s = reader.readLine();
    bindTemp = response.getResponse("$0001").getTemperature();
    bindVolt = response.getResponse("$0001").getVoltage();
    } catch (e:Exception) {
    System.err.println(e);
    }.play();
    The ConnectionRefused error occurs only when the NetBeans Project Application Properties "Draggable Applet" checkbox is checked ( which is the default ). Once I uncheck it, the error goes away.
    -Richard

  • Connect two applet

    Hi,
    Can any1tell me how to connect two applets running on different browser. This is fro a chat program. So I want to pass message from one end to other. I suppose it can be done by using servlet plz send me some ideas (some code would be a great help).
    Thankyou in advance
    : > Waiting.................................................

    I already did that. I tried to connect them using raw socket connection but that didnt work then on sm1 advice i tried to use URL and URLConnection but that didnt work either . Ok i elaborate the concept a bit plz read it carefully:
    Have u ever visited any e-commerce sites which provide products for online sale. Such sites generally have online chat support to chat with the site visitor and provide necessary info he wants. I am trying to make such a chat system. For this purpose i developed two applet in which one applet listen to specific port using ServerSocket (that is for the chat center interface let say Agent applet) and another applet when invoke by site visitor(let say visitor applet) tries to connect the first one using Socket connection. Agent applet is in admin folder. This technique is not working the visitor applet cannot connect the Agent applet although both can start by the browser successfully.
    I uploaded myboth the applet on following link you can take a look on:
    Agent applet: www.geocities.com/launchpad143/Agent.html
    Visitor applet: www.geocities.com/launchpad143/ClientChat.html
    Note:First let the Agent applet loads completely then start ClientChat applet
    I dont want to signed the applet because it gives the option to the visitor to accept or decline that i dont want. Also i didnt touched the java policy file to give any permission (But it is not throwing any exception related to that. I am not sure to give any extra permission or not also i dont know what n how).
    Then sm1 from this forum told me that it is not possible to connect two applets like this i have to use servlets. Now you tell me how to do it?
    Thanx for your responce but the problem persist
    :(

  • Socket connect slow in JDK 1.5?

    We recently began testing our Java Swing application with JDK 1.5, and we noticed that socket.connect()
    calls are taking several seconds to return, when before in 1.4 the calls returned immediately.
    Here is some sample code:
    Socket sock = new Socket();
    InetSocketAddress sockAddr = new InetSocketAddress(inAddress, portNum);
    sock.connect(sockAddr, 2000);
    What could be wrong? I've debugged the code and verified inAddress is an IP address,
    not a hostname.
    -Eric

    Here is the list of enhancements in JDK1.5.
    http://java.sun.com/j2se/1.5.0/docs/guide/net/enhancements-1.5.0.html
    I wonder if any of them are having some effect in the slow connection.
    There are some network properties that you can tweak with. Did you try them?
    Here is the list
    http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html

Maybe you are looking for

  • Mini DVI to VGA problem

    Hello, I just recently bought the mini DVI to VGA adaptor for my new MacBook because I wanted to use my laptop as a dvd player and plug it into the TV in my room. The TV is a Samsung LCD ln S1951W, when I plug it in the computer detects the display b

  • Creating data in a many-to-many-relationship

    Hello, we really have problems in implementing a JClient dialog based on BC4J for creating data in a many to many relationship - especially with cascade delete on both sides. Simplified our tables look like: create table A_TABLE A_ID VARCHAR2(5) not

  • Error in bex design window while Restricting an item in a query

    Hi All, When I try to restrict an Item (a value)  in the query design window Im getting the following errors:- 1.) 'The Operation Failed because of a program error on the Server (DUMP). See System Log for Details.' 2.) 'Stop Statement Occured'. 3.) R

  • FCP Project Management

    Hi, I need some software that puts each new project into it's own folder on my SAN and keeps everything to do with the project in that folder. So for example, the directory structure would look like this; Root |_ Projects |_ Project 1 |_ Audio Render

  • AN odd sql script run on server every 20 seconds

    I run profiler trace T-sql for one day today, and I see below script run under sa account every 20 seconds on the server: select table_id, item_guid, oplsn_fseqno, oplsn_bOffset, oplsn_slotid  from [DB_Name].[sys].[filetable_updates_1983398185] with