Communication between applets using socket

Hi,
we have an application in which based on certain criteria a video is bieng played in the applet on same machine.Now we have to separate the video component from the application part so that video can be played separately. they will be communicated using socket.Can any body tell me how to go about for the solution.

To do this you must have a server application listening to a port on a server box that has a fixed IP. In your Java app, you need to create a Socket connection back to the server (may need to sign your jar - but maybe not)
voila you're there.
You may want to search google + these forums for my InfoFetcher class which is built to grab data from an inputstream and report updates to listeners

Similar Messages

  • No communication between applet - servlet

    hi
    my applet and my servlet is not at all communicating in the browser.
              any body knows how to solve this problem?
              in my applet code:Jus i am pasing as name string to invoke the serlvet via URL
              String location = "http://ctp-vi0275:8880/HandlePassword?"+"Name=XXX";
              URL testServlet = new URL( location );
              URLConnection servletConnection = testServlet.openConnection();
              servletConnection.setDoInput(true);
              servletConnection.setDoOutput(true);
              servletConnection.setUseCaches (false);
              servletConnection.setDefaultUseCaches (false);
              servletConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              servletConnection.connect();
              i have changed server.xml file to listen the port number 8880.(in tomcat)
              in my servlet code:
              doGet Method in servlet
              String str = req.getParameter("Name");          
              System.out.println(str);
              here i am jus printing the name
              but when i run my applet is not at all invoking the serlvet - HandlePassword.I have placed the
              servlet in ROOT\web-inf\classes\HandlePassword
              in web.xml
              <web-app>
              <servlet>
              <servlet-name>HandlePassword</servlet-name>
              <servlet-class>HandlePassword</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>HandlePassword</servlet-name>
              <url-pattern>/HandlePassword</url-pattern>
              </servlet-mapping>
              </web-app>
              where i am doing wrong here?

    You do following things and let me know:
    1. Does the servlet work when you type "http://ctp-vi0275:8880/HandlePassword?Name=XXX" in your browser?
    2. Run applet using appletviewer. Does it work?
    3. If it works using appletviewer then enable java console in your browser and see error stacks if any.
    4. If there are applet security errors on java console, try creating servlet URL in applet code by calling getDocumentRoot() method and see what happens.

  • Communicating between subpanel using main vi

    Hi all,
    I have three VIs. One main VI and another two VIs that I load the into
    the subpanels in main VI. The main VI is used to handle communicating
    between these two VIs that load into subpanels. I used queue method to
    communnicate between VIs. I want to add data from Panel - Add Data.vi
    when I click Add button into multicolumn listbox in Panel - List.vi.
    When I run both VIs, the Add button can transfer data into multicolumn
    listbox, but it doesn't work when I load them into subpanels in
    Main.vi. Can somebody help me to solve this problem.
    Thanks in advance.
    Attachments:
    Communicating between subpanel.zip ‏72 KB

    Hi MikeS81;
    Actually, at this moment I only want to add data (by using Add button in Panel - Add Data.vi) into listbox in Panel - List.vi. Because both of VIs are load into subpanels in main VI, I used global variables to make it easier, and the important thing that I don't have an idea how to do that. Can you give me a simple examples to do that because to add data into listbox, it uses a ItemNames property which for me it is very dificult... For your second question, later I may be want to send data in both directions.
    Thanks for your answer.

  • 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");

  • Communication between Applets & Servlets

    How do you communicate in between Applets & Servlets ?

    http://forum.java.sun.com/thread.jsp?forum=45&thread=525518&start=0&range=15#2519429

  • Socket communication between applet and an AP on simulastor

    Hi!
    I implemented my system under Server/Client model.
    The server is running in a Set-Top-Box simulator, which
    creates a ServerSocket on port 9190.
    The client is an applet and using the following codes to connect to server:
    ==========================================
    Socket socket = new Socket("127.0.0.1", 9190)
    InputStream in = socket.getInputStream();
    OutputStream out = socket.getOutputStream();
    ==========================================
    When I start the applet, no exceptions are thrown,
    and objects socket, in and out are not null.
    But when I was trying to send a string to server,
    ==========================================
    out.write("a string".getBytes());
    ==========================================
    nothing happened. Server didn't get anything.
    What's wrong? How can I solve this?

    First of all "nothing happend" is something you tell the DELL helpdesk.
    This is a developer forum.
    My guess is you are using somthing of a in.readLine() on the server and since the
    client doesn't sent a linebreak it will hang there.
    Or the client gets an AccessControlException that you silently catch and therefore get
    no exception. Allthough the InputStream would be declared in the try block (according
    to posted code) and can not be checked for beeing null in the catch (out of scope).
    Here is some sample code of client and server, try to implement the run method in
    your client and run both appTest and applet on the local machine (http://127.0.0.1).
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    public class appTest implements Runnable {
         public appTest() {
              new listner().start();
              new Thread(this).start();
         // main program
         public static void main(String argv[]) throws Exception {
              new appTest();
         public void run() {
              // the client
              try {
                   Socket s = new Socket("127.0.0.1", 9190);
                   // if multiple messages are to be sent and received
                   // this is where you start a new thread
                   byte b[];
                   OutputStream out = s.getOutputStream();
                   InputStream in = s.getInputStream();
                   String message = "hello from client";
                   int messageLength = message.getBytes().length;
                   // writing the length of the message
                   out.write(new Integer(messageLength).byteValue());
                   b = message.getBytes();
                   // writing the message
                   out.write(b);
                   // reading the length of the message and setting the byte array to
                   // it
                   b = new byte[in.read()];
                   in.read(b);
                   // receiving the message
                   System.out
                             .println("received massage from server: " + new String(b));
                   out.close();
                   in.close();
              } catch (Exception e) {
                   e.printStackTrace();
         class listner extends Thread {
              public void run() {
                   try {
                        ServerSocket srv = new ServerSocket(9190);
                        while (true) {
                             try {
                                  System.out.println("before accepting a client");
                                  Socket s = srv.accept();
                                  System.out.println("after accepting a client");
                                  // if multiple messages are to be sent and received
                                  // this is where you start a new thread
                                  byte b[];
                                  OutputStream out = s.getOutputStream();
                                  InputStream in = s.getInputStream();
                                  // reading the length of the message and setting the
                                  // byte array to
                                  // it
                                  b = new byte[in.read()];
                                  in.read(b);
                                  // receiving the message
                                  System.out.println("received massage from client:"
                                            + new String(b));
                                  System.out.println("sending message from server:");
                                  String message = "hello from server";
                                  int messageLength = message.getBytes().length;
                                  // writing the length of the message
                                  out.write(new Integer(messageLength).byteValue());
                                  b = message.getBytes();
                                  // writing the message
                                  out.write(b);
                                  out.close();
                                  in.close();
                             } catch (Exception ex) {
                                  ex.printStackTrace();
                   } catch (Exception e) {
                        e.printStackTrace();
    }

  • Applet using sockets works perfectly under Netscape but not under IE

    I have setup a java applet compiled with Sun Forte which implements a connection with a server application with sockets. The applet works perfectly on the same machine when it is loaded from netscape communicator but I receive an com.ms.security.SecurityExceptionEx security error when I am trying to connect on 127.0.0.1:7000. How can I solve this problem I have with IE. I would like to thank you on advanced.

    Hi,
    if ur applet want to open socket in IE you need to import microsoft java package which is in Microsoft SDK for Java 4.0.
    import com.ms.security.*;
    try {
    if (Class.forName("com.ms.security.PolicyEngine") != null) {
         PolicyEngine.assertPermission(PermissionID.NETIO);
    } catch (Throwable cnfe) {
                   System.err.println( cnfe.toString() );
    you have to write above code and compile the java file by using jvc.exe which in Microsoft SDK for Java 4.0.
    You can download Microsoft SDK for Java 4.0 from microsoft site.
    try & all the best
    sundaram

  • Communication between applets that are in different frames

    Hi,
    I have two applets in the same browser page but not in the same Frame, and I'm trying to invoke a method of one of the applets from the other. getApplet("NAME") does not work because both are in different frames.
    I have managed to do the communication with a static method, but the invoked method doesn't have the correct variables values (also defined static), these variables have the default values (i.e. int = 0).
    My program:
    Applet A --> loads the data and waits for Applet B's invocation.
    Later....
    Applet B --> invokes an Applet A's static method, Applet A receives the data, Applet A is supossed to work correctly, but its data is not the previously loaded but the default values.
    What am I doing wrong? Looking at this, it seems that the static method invoked is from a different class.
    Has anyone any working example? Is there another way (not signing)?
    Thanks

    You could do it using javascript. From what it looks like you are describing :
    In Applet A's page, have a javascript function that looks like the following :
    function callAppletB()
         self.parent.frame[1].document.getElementById("insert applet b's id here").methodName();
    }Then, in Applet B's page, make a similar function :
    function callAppletA()
         self.parent.frame[0].document.getElementById("insert applet a's id here").methodName();
    }Just make sure that Applet A's page is the first frame on your frameset page. Hope this helped.
    Ed

  • Applet using sockets works perfectly under Netscape but not under IE securi

    I have setup a java applet compiled with Sun Forte which implements a connection with a server application with sockets. The applet works perfectly on the same machine when it is loaded from netscape communicator but I receive an com.ms.security.SecurityExceptionEx security error when I am trying to connect on 127.0.0.1:7000. How can I solve this problem I have with IE. I would like to thank you on advanced.

    for ie you need a certificate that tells ie the applet if safe and allowed to open system-resources.
    take a look on the Forum: Signed Applets.
    regards

  • Direct Connection between clients using sockets

    Hi, I'm a new user and i have a problem with sockets:
    The question is how can i directly connect two users that are already connected to a server in other machine???
    I mean
    user1 is connected to server
    user2 is connected to server
    user1 tries to communicate with user1 but don't want to use the server, and the server only provides the client1's ip
    I first thought to do this:
    user2 asks to server for the info of a client1-server waiting for connections, and i think it could work fine, but only if the ports are not closed by firewall, because client-server will be running in a transparent mode for user and user may not know anything about servers, sockets, ports, etc. the user only will work with a gui or something else and that's all
    Does anybody know what can i do to make this possible???
    PD
    Sorry for my bad English

    It can be implemented like you said. Make one of the clients open a serversocket and pass the ip and port number through the server to the other client with information on where to connect.
    If you're going to use direct connection between clients a lot then I would recommend that every client open a default serversocket at startup and register that information with the server and then every other client can ask the server for the ip and port to whatever client they wish to open a direct connection to.
    Be aware that clients often are behind NATs and firewalls, so if need to deal with those issues you got to use hole punching (http://en.wikipedia.org/wiki/hole_punching) - pref on a known port like 80 - and to deal with the less frequently used application firewalls you can use http encapsulation in addition.

  • Communication between applet and Web app (IE6 works IE7 doesn't)

    I'm not 100% sure this is the correct forum to post this in, but as the communication is initiated from the applet I'm posting it here.
    I have an applet that we are slowly breaking pieces out of into a web app.
    The details are as follows.
    The applet calls a servlet on the webserver with the following code.
    URL url = new URL("http://.................");
    ServletMessage message = new ServletMessage(url);
    InputStream returnStream = message.sendPostMessage(sending);The servlet takes the user credentials and other info that was sent and authenticates the user and stores the info that was passed into the session on the web server. Then based on the users permissions and where they want to go in the web app the servlets redirect method calls
    resp.getOutputStream().print("/AppName/appropriateServlet");This sends control back to the applet (including the url of the servlet that needs to be called) which then calls the appropriate servlet
    container.getAppletContext().showDocument(new URL("http://.............." + returnURL), "Title");Now the problem is that in the first and second servlet the request.getSession() returns two different sessions when running under IE7. IE6 returns reference to the same session.
    I don't know what has changed in IE7 but I was hoping somebody else has run into this, or can suggest a more appropriate forum to post this to?
    Thanks

    So the solution I came up with was when the applet jumps to the web app the first time instead of storing everything in session I store them in a map in the servletContext under their employee number.
    I then send control back to the applet with the url they should call. When the applet calls the web app for the second time it includes their employee number as parameter in the url.
    A Login filter then first checks to make sure it isn't on the first call, and checks to make sure they aren't in session... if so it pulls the map out of servletContext and transfers all the data back to the session and clears that user out of servletContext.
    So it stores the user in the servletContext during the transfer back and forth, then back in session like normal.
    I'm pretty sure it is going to work, but I can't test it because our mainframe test region is down which is what handles the authentication of the applet.

  • Communication between ServerSockets and Sockets

    Hi, I'm working on a multi-player blackjack game but hitting a small hitch. I have a Game class that sets up a ServerSocket and a Player class that creates Sockets that connect to this ServerSocket. Once the connection is established I create a thread for each player that will basically handle getting input from the user about what the player would like to do.
    Here's the problem: Within the thread I send a little prompt to the player asking for input. The user can then input but what happens is the writeObject call tries to send the response back to the Game class where it's not longer sitting handling the socket (the socket that was used for the initial connection has been passed to the thread).
    Is there anyway I can get the Player to talk directly to the thread that's handling that player without creating more ServerSockets (I don't want more than 1 server).
    Thanks,
    Josh

    The Game class should be looping calling ServerSocket.accept() and starting a thread for each accepted Socket. It is this Socket that will receive the data sent by writeObject(). It sounds like you haven't done this part.

  • Communicating between Applets on same web browser page.

    I one wishes to do variable/function calls between seperate applets on one page,
    -is there a simple way to do this (i.e. a global context object as a go between)?
    Could I have/be pointed to an example?

    Global context indeed. Your Applet will have a getAppletContext() method which returns an... AppletContext! And that has a getApplet(String) method which gets a reference to some other applet in the same context. The API documentation for that method contains more information than what I've posted here.

  • Communication between applets.

    Could you help me with a program where I have to send a JLabel to another applet?
    My problem is that when I pass a Box object, it doesn't appear, so I have to create it again, but when the thread starts and the JLabel has to move, then appear two Box objects moving.
    Here, in this link is some of the code because I posted this problem in the New to Java section.
    http://forum.java.sun.com/thread.jspa?threadID=5292745&messageID=10236628#10236628

    Here is the class:
    import java.util.Random;
    import javax.swing.JApplet;
    import javax.swing.JLabel;
    public class Caja extends Thread {
        JLabel etiq;
        int pxi, pyi, pxf, pyf;
        JApplet vv;
        int pos;
        int dir,via;
        Random rr;
        public Caja(int xini, int xfin, int yini, int yfin, JApplet ff, int ps) {
            pxi = xini;
            pxf = xfin;
            pyi = yini;
            pyf = yfin;
            pos = ps;
            vv = ff;
            etiq = new JLabel();
            etiq.setBackground(new java.awt.Color(204, 204, 255));
            etiq.setOpaque(true);
            vv.getContentPane().add(etiq);
            etiq.setBounds(pxi, pyi, 30, 20);
            rr=new Random();
            via=rr.nextInt(3)+1;
        public void run() {
            while (true) {
                if (etiq.getX() < pxf) {
                    etiq.setLocation(etiq.getX() + 5, etiq.getY());
                if (etiq.getX() == pxf && pos % 2 == 0) {
                    if (etiq.getY() < (265 - (pos * 20))) {
                        etiq.setLocation(etiq.getX(), etiq.getY() + 5);
                if (etiq.getX() == pxf && pos % 2 == 1) {
                    if (etiq.getY() < (265 - ((pos - 1) * 20))) {
                        etiq.setLocation(etiq.getX(), etiq.getY() + 5);
                if (dir == 2){
    if(etiq.getX()==pxf&&((etiq.getY()==(265-(pos * 20))) || (etiq.getY()==(265-((pos - 1)*20)))))
                    while (etiq.getY() > 20 && etiq.getX() == pxf) {
                        etiq.setLocation(etiq.getX(), etiq.getY() - 5);
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                    if (etiq.getY() == 20 && etiq.getX() < 240) {
                        etiq.setLocation(etiq.getX() + 5, etiq.getY());
                    if (etiq.getX() >= 240 && etiq.getX() < 265) {
                        etiq.setLocation(etiq.getX() + 5, etiq.getY() + 8);
                    if (etiq.getY() < 250 && etiq.getX() == 265) {
                        etiq.setLocation(etiq.getX(), etiq.getY() + 5);
                    if (etiq.getY() >= 250 && etiq.getX() < 330) {
                        etiq.setLocation(etiq.getX() + 5, etiq.getY());
                if(dir==3){
                    if(etiq.getX()<pxf){
                    etiq.setLocation(etiq.getX()+5,etiq.getY());
                    switch(via){
                        case 1: while(etiq.getX()<130 && etiq.getY()>30){
                                etiq.setLocation(etiq.getX()+5,etiq.getY()-5);
                                pausa(50);                  
                                break;
                        case 2: while(etiq.getX()<200 && etiq.getY()==250){
                                etiq.setLocation(etiq.getX()+5,etiq.getY());
                                pausa(50);
                                 break;
                        case 3: while(etiq.getX()<130 && etiq.getY()<400){
                                etiq.setLocation(etiq.getX()+5,etiq.getY()+10);
                                pausa(50);
                                break;
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
        public void pausa(int vel){
        try {
                    Thread.sleep(vel);
                } catch (InterruptedException e) {
        }Edited by: javnik400 on May 7, 2008 1:46 AM

  • I need to multiplex communication between threads and sockets

    Hello,
    I need to implement a server which will have a maximum of 10 clients connected.
    I wanted to go for classic blocking I/O because I won't have much clients.
    My problem is that even if I accept() some sockets and then create a thread for each socket,
    then I still need to communicate some data to the other threads, problem is that I am blocked
    on the read() operation, how could I address this problem?
    I mean, lets say I am thread1 and blocked on read() on my socket, now thread7 wants to tell
    me something like a chat message coming from client he handles, how could thread7 manage
    to wake thread1 and send him a message somehow?
    I do not want to deal with NIO stuff if possible because I do not need to scale, I just have a
    problem because I am stuck on the read.
    I will run on Windows.
    Thanks for help.
    Edited by: Marzullo on Jul 15, 2010 1:05 PM

    Marzullo wrote:
    Hello,
    I need to implement a server which will have a maximum of 10 clients connected.
    I wanted to go for classic blocking I/O because I won't have much clients.
    My problem is that even if I accept() some sockets and then create a thread for each socket,
    then I still need to communicate some data to the other threads, problem is that I am blocked
    on the read() operation, how could I address this problem?For small apps like that, I've found it helpful to have two threads per socket: 1 reader and 1 writer. The reader can block on read() 99% of the time, while the writer is blocked on LinkedBlockingQueue.take() 99% of the time (or Object.wait() depending). The writer's queue is populated from the outside with whatever messages are destined to that socket.
    I mean, lets say I am thread1 and blocked on read() on my socket, now thread7 wants to tell
    me something like a chat message coming from client he handles, how could thread7 manage
    to wake thread1 and send him a message somehow?If thread1 is blocked on read() then it will receive any data that was sent to it, there's no need to wake it up because it gets what it's been waiting for (data on the input stream). Thread7 just needs to write data to the socket's output stream and the other end wakes up automatically because read() only blocks until data is available.

Maybe you are looking for

  • How to remove a disk from a logical-drive in a 3510

    Hello SUN masters, I have a 3510 with 4 logical drives and 2 global spares. Logical drive 0 (ld0) has 14 disks and i want to assign 2 of those as global spares and leave ld0 with 12 drives. the other logical-drives have just 2 HDD so I won't touch th

  • Oracle export error

    Hi I am trying to export a table with 2 million records and getting below error. exp user1/user1 buffer=8192 compress=y file=Test_table.dmp tables=test_table filesize=8192000000 Export: Release 10.2.0.1.0 - Production on Mon Oct 29 12:49:23 2012 Copy

  • Safari 8.0.2 will not launch after a crash

    Safari quit unexpectedly (when I tried to download a photo app), got pop up window asking me to select restart which I tried and it just keeps popping back up and won't restart.  Tried the "hold down the shift key" and nothing.  I've restarted and it

  • Cs6 does not regiser in my Win 7 Registry

    I tryed to change my .JPG files to default to CS6, I go thru all the procedures but CS6 does not show up in my sysem default program list.  The answer from Microsoft  is the CS6 did not register in the system registry when I installed it.  How do I a

  • Oracle E-Business Suite Release 12.2.2 Media Pack v1 for Linux x86-64-bit avaliable NOW!

    Hi Friends; Finally Oracle E-Business Suite Release 12.2.2 Media Pack is available at e-delivery site. For a now it has been published for linux x86-64. Setup size almost 83G Here is the some notes: New Installation Customers who do not have access t