2-way communication with an Applet, is it possible?

I have read a couple of things on the internet that states that Applets cannot create ServerSockets. Is it really true, that you cannot directly communicate to an Applet unless it is polling a server???? There must be some other way, if any one can help, I would be greatly appreciative.
Thanks!
Blaine

I have read a couple of things on the internet that
states that Applets cannot create ServerSockets. Is it
really true, that you cannot directly communicate to
an Applet unless it is polling a server???? There must
be some other way, if any one can help, I would be
greatly appreciative.
1. An applet can do anything that java can, including opening sockets to anything it wants, JNI, file access, etc. However, an applet works in a sandbox and normally it can't do any of those things. So you must do additional work to allow it to do such.
2. A socket back to the server is a two way communication pipe. Information can move both ways. In most designs this is the only way that you want communications to move.
3. An applet talking directly to another applet probably isn't a good idea. There are several reasons, one that springs immediately to mind is that the two boxes in the communication might not be addressable to each other (both have private IPs and are on different subnets.) With a server in the middle this is not a problem, but it is not possible otherwise.

Similar Messages

  • Error message saying "unable to establish two-way communication with device"

    I have an HP C309a printer/scanner/fax. I have recently reconfigured it to work wirelessly instead of via the USB cable, which it does. But if I try to go on to  the HP Solution Centre/Settings/Printer Toobox to clean the printheads, it tells me that this cannot be done because "the computer cannot establish two-way  communication with the device".
    If I plug the USB cable back in, I can clean the printheads fine.
    Does anyone have a way of allowing me to clean the printheads without using the USB cable?
    roger

    Hi rogercorke,
    I believe you can also clean the printhead from the printer control screen. Press the Wrench button from the printer Home screen and then press Tools>Clean Printhead.
    If you need to use this feature wirelessly, try running the HP network diagnostic utility on your wireless setup and see what it says: http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?cc=us&lc=en&jumpid=ex_r4155/en/hho/ipg/foru...
    Please click the blue Kudos star in the post that helped you. 

  • The computer is unable to establish a two way communication with the device

    Hi  I am trying to fix a problem for some one else, and I am struggling where to look next. The issue is that we are unable to check the ink levels of a HP Deskjet 1050 printer.  The error message states that the computer is unable to establish a two way communication with the device. After running through the troubleshooting guide about this issue on the HP site with no joy,  I decided that it may be the printer and suggested a replacememnt.  Unfortunately A new HP Envy 5530 was purchased and connected (wirelessly) but the issue remains. I have uninstalled the drivers multiple times, and also disabled any firewall/anti virus software in case this was interfering. I was hoping that some one could point me in the right direction next? None of the other forum posts here (or any google searches) give a solutuon which has fixed the problem.  Thanks

    No I cant. Unable to ping the printer too, not sure if this is possible normally?

  • Digital Fax to Folder Setup gives error message unable to establish 2-way communication with device

    Digital Fax to Folder Setup gives error message unable to establish 2-way communication  with device. I can s end a Fax and I can print documents. I can also, now, scan to computer. I have changed the phone line twice, restarted the router, restarted the computer, and made sure the front panel was lit when setting up the Digital Fax folder. I am on a Homegroup network, with both wireles and ethernet computers.  When I view the network, it sees both computers (wireless laptop and enthernet desktop), the printer, scanner, and router (VerizonDrive). I recently had to reinstall Windows 7, where Digital Fax to Folder Setup previously worked, and now it doesn't.  The network shows up as Network 3. When I try to view the network map, I get the error message that Windows cannot create the network map. Responses from other devices on the network are delayed or there is an  incompatible router on the network.  What am I doing wrong?

    Hello @JiffyFingers and Good Afternoon
    From what you have described, and from the work you did on another thread, I believe you'd get better assistance talking to either Microsoft or your router manufacturer. With not being able to create the network map, that's something a bit more intricate than digital fax setup
    You can have a look at this Windows cannot create the network map. Responses from other devices on the network are delayed or th... Microsoft thread as well, and you may be able to figure it out from there.
    Hope that helps, have a great day!
    Please click “Accept as Solution ” if you feel my post resolved your issue, as it will help others find the solution faster
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    **MissTeriLynn**
    I work on behalf of HP

  • Unable to establish the two way communication with printer j110a

    every thing is ok but during the printing or ink level checking this message displayed "unable to establish the two way communication with printer j110a" please reply soon?

    Hard Reset – While printer is powered ON, pull the power cord from the printer then from the wall. After 30 seconds reconnect power to wall and printer. This will trigger a ‘dirty power up’ and restore the printer to a known good condition (if it is possible). No user settings are lost with a ‘hard reset’. This ‘Hard Reset’ is one of the most powerful tools to use when the printer hardware is not functioning properly! IF NOT RESOLVED, uninstall hp software & reinstall using latest hp software from hp website.
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • Unable to establish two-way communication with the printer

    I have a HP Photosmart B8550 large format printer, but failed recently to print the whole page, but only one third of the page.  The OS is Window 7 in my commuter.  I downloaded the driver from HP website, but it is not working.  The result of the failure is "The computer is unable to establish two-way communication with the device."  One of the reasons I guess is that I failed to register my printer because I had no way to finish the registration, because there is no further process even if I put my printer name or number into the required block.  Anyhow I failed recently to print anything in the printer.  I am seeking the support after a lot of tries.  Thanks. 

    I have two HP computers and two HP Photosmart B8550 printers.  A month ago printers were not working.  I tried in vain in two computers to download new HP software and driver from internet and got the HP Solution for install error - Windows 7.  Based on this Solution on desk, I tried many many times to follow every step, but the result is the same:  Fatal error during the installation.  
    By using other tools like HP Printer Diagnostic Tools, HP Print and Scan Doctor, I failed too because the diagosis or the choices are not accuate.  For example, the printer is disconnected.  It is wrong even if I changed ports and USB calbe again and again.  The control panet can prove that there is communication, but the printer cannot work as directed.  There is no way to test the printing as Doctor requested, saying the computer is unable to establish two-way communication with the device, which is not helpful to go ahead with the solution.  There is no way to register the printer because there is no such a model HP Photosmart B8550 in its list after search.  
    It is even worse that the new window dialogue asked me to find HP Photosmart Essentials in my computer to install it again and again, and I could not concel the request whenever I open my computer.  
    I guess the HP printer software and driver has something wrong in its root design, which leads me to failure in installation so that the computer could not recognize my printer.  In short, the new HP software and driver makes my printer not functional.  
    By the way, my two printers can work internally in printing sample paper and report and two computer are working in perfect condition. 

  • 2 way communication

    What is the best way to get 2 way communication with a servlet from a Java Web Start Application using http protocol?
    Is this something related with http 1.1?

    See http://www.j-nine.com/pubs/applet2servlet/Applet2Servlet.html
    This is for applet-to-servlet but should work similarly.

  • 2 way communications error

    unable to determine ink level - "the computer is unable to establish two way communication with this device" - what do I need to check   C3180

    Hi --frustrated,
    Welcome to the HP Consumer Printer Forums! 
    I would like to help, but need a little more information regarding your issue, what operating system is your computer running?
    If I have helped in any way, just click the Kudos star on the left. Also, if your issue has been resolved, don't forget to select Accept as Solution

  • How do i fix the inability to establish two-way communication between my computer and the printer?

    HP Photosmart 5510 e-All in One Printer B111a
    Windows XP
    Message "The computer is unable to establish two-way communication with the device."
    Installed new printer
    I'm simply trying to get the estimated ink levels.

    Please make a Genius Appointment and take it in for service.

  • Computer unable to establish two-way communication to J4580 through Airport Extreme

    I have my J4580 connected to an Airport Extreme base station via usb.  I've installed the printer software on my HP laptop (Vista) and Bonjour recognizes the printer as networked & installed, but when I try to print, i receive an error message "Computer is unable to establish two-way communication with the device" and the printer queue shows an error.  I've attempted to find a solution through the posts, but haven't seen much that seems to apply to J4580.  Any help???  Thanks!

    I came across this similar problem and spent days trying to figure it out. I knew I was close when I tried to start the HPZ12
    service and it kept failing with "unable to find the specified file". I traced it with a process monitor and found that it was looking
    for a registry key that was not present. Specifically:
    HKLM\System\CurrentCosntrolSet\Services\Pml Driver HPZ12\Parameters
    It was looking for the string:
    ServiceDLL which should be set to:
    C:\WINDOWS\system32\HPZipm12.dll (or something similar)
    The unfortunate thing is that no matter how many times you install and uninstall the HP drivers, then don't reset the registry keys
    for the HPZ12 service. In the end, I ended up doing the following:
    1. Uninstall software and reboot
    2. Go through registry editor and delete the PML key (just did a search for all PML occurences)
    3. Deleted the c:\program files\Hewlett-Packard directory
    4. Deleted the c:\program files\HP directory
    5. Deleted the c:\windows\system32\spool\drivers\w32x86\ contents (anything that referred to an HP printer or driver)
    6. Deleted the HKLM\Software\Hewlett-Packard registry key
    7. Rebooted
    8. Reinstalled and everything worked.
    I suggest you backup any registry keys prior to deleting them in case you make a mistake. You can use the Export feature on
    the right-click context menu to save each key you delete, or use some tool to make a backup of your registry prior to making
    these changes. Similarly, for the files, I renamed directories or created backups of their contents.
    Once I reinstalled, I found that there were TONS of new registry keys added that weren't there before. So the real problem is
    with HPs install/uninstall. It doesn't clean up properly and any aborted or failed instalation will leave the drivers in a poor state.

  • HT202000 Is there a way to have multiple audio sources sent to multiple outputs (i.e. communications with skype sent to headset, music sent to speakers )

    Is there a way to have multiple audio sources sent to multiple outputs (i.e. communications with skype sent to headset, music sent to speakers ) I do this on my Windows but cannot find for mac.  I am transitioning from Windows brain to Mac brain and having a little difficulty
    OS Yosemite

    Is there a way to have multiple audio sources sent to multiple outputs (i.e. communications with skype sent to headset, music sent to speakers ) I do this on my Windows but cannot find for mac.  I am transitioning from Windows brain to Mac brain and having a little difficulty
    OS Yosemite

  • Java communication with applets

    Hi, I'm new so I hope this is where I should post this question.
    Basically, I want to write a java program that communicates with an applet and retrieves data from the applet. The applet is executed from secure http protocol and connects via the socket port. I know the applet is MainClassApplet.class, but I do not know any of its methods, variables, constructors, etc.
    Is it possible to communicate with this applet and retrieve information from it?

    The jar file is just a resource on the web server,
    like the web page that it's called from. You could
    use your browser to grab the jar file. Or use
    something like curl.hmm.. do you know of some code or tutorial I could
    look at for this?Look at the HTML source of the web page that includes the applet. From that page's URL, and the <applet> or <embed> or <object> tag that refers to the applet, figure out the URL to the jar file. Then type that URL in the location bar of your browser.
    Or get "curl", which is a command-line utility that acts like a browser, and use that to get the file. Read the curl help pages.
    User name and password doesn't necessarily have
    anything to do with HTTPS. Is the site also using
    HTTP authentication, or what? How do you know it
    wants your user ID and password?Well, why would they make you pay for an account if
    people could easily access their webpages? Sometimes a site will password-protect some pages but not others. And anyway, are they asking for a user name and password or aren't they?
    I just
    know it uses a post method in order to retrieve a
    user's account name and password.. I don't think it
    uses HTTP authentication.. It has 4 parameters that
    it uses to execute the post method.Well, that tells me almost nothing.
    Before trying to grab and reverse-engineer some functionality from a site, probably in a manner that violates whatever agreement you agreed to when you signed up for the site, you might want to learn about basic web technologies, like HTML, HTTP, etc. Then learn basic Java.

  • Applet not communicating with servlet when given ip address (not localhost)

    I have a strange problem with my applet -
    I have a java applet and a Tomcat server running. I am able to communicate between the applet
    and a servlet on the server (sending strings from applet to servlet, for example..) when the
    URL that I write in the applet is -
    "http://localhost:8080/ProjectName/ServletName "
    BUT - when instead of that "localhost" I insert my ip address, it throws the exception:
    java.net.ConnectException: Connection refused: connect
    in the line -
    urlConn.getOutputStream(); (urlConn is the HttpURLConnection that I created with the URL)
    also, I did port forwarding (I have a router)
    so that 8080 port will be directed to my computer, and tested the forwarding, and it does work.
    Does anybody know why there is a problem?
    Thank you.. :)

    >
    well, in the final version of the project the applet will be signed.. >Uh-huh..
    >
    but, I got tired of signing it every time I edited the code, so now I just simply run it as a "java applet" project
    from the eclipse.. NOT as a signed jar..>Eclipse has Ant built in. Write a script that will compile/build/sign the jar for you, then build it to the point of being signed for every test run. (Just today I was making some changes to a signed applet project that does just that - I probably built it 25 times before I was happy with the changed code - not a problem.)
    >
    you think that's the problem ?>Yep. Not that I provide support for Eclipse, nor know how it goes about launching applets (trusted or sandboxed).

  • Keeping contact with controlling applet while u/l XML file via servlet

    Hello everybody,
    if I am thinking too complicated, please send me other suggestions. Here's the situation:
    I already have a working applet for a metadata application, that is sending the contents of the client's textfields to a remote database via servlet communication. Now I want to implement the following:
    -The users have some attribute data in form of an XML file
    -I want them to upload this file to the server (I already have that functionality using the fileUpload libraries of Apache Commons) by calling the servlet from a pop-up html page (is there any other possibility to do the communication, i.e. getting files from the file system?)
    -the XML file should be parsed on the server and the content should be sent back to the calling applet for previewing reasons.
    -when the user gives his/her O.K. the data should be transferred to the database.
    Now there are some obstacles to overcome: When I upload the XML file to the server, I loose "contact" with the applet, i.e. the file is not connected with the applet code in any way. This is not a problem, when there is only one user at the time, but with many users loading up their data at the same time, things could get tricky.
    What I thought was to copy the XML file to a temp directory with a unique name, the name of which would be transferred back to the applet by another servlet that is called when the (upload)pop-up window closes. The name of the temp directory could be the ID of the applet thread (is there such an ID, if yes, how can it be retrieved?)
    Any suggestions (or just shaking heads concerning my complicated construction ;-) )
    Cheers and many thanks in advance
    Jan

    You may be able to read a file from the file system with the applet, but it may require you to sign the applet. If you can, then use an HttpURLConnection to the servlet and send the file that way.
    On the server side, you could create a session object (wether you actually need a session or not), and use the session's id as the key id for the directory name for the uploaded file. Session IDs are unique per client, and if the client handles cookies, then the same session will be used from one request to the next.
      session = request.getSession();
      String sessionID = session.getId();The response from the servlet would be a link to the server-side file. If you are using the Applet to send the request, you could get the response and automatically view the new file. Otherwise, you could send a page to the popup window saying: "Click This Link To See Your File" type of thing.

  • Trying to Imitate the html POST  method with an applet

    I am trying to imitate the POST method with an applet, so that I can eventually send sound from a microphone to a PHP script which will store it in a file on a server. I am starting out by trying to post a simple line of text by making the PHP script think that it is receiving the text within a POST-ed file. The reason I am doing things this way is in part because I am, for the time being, limited to a shared server without any support for servlets or any other server side java.
    The code I am trying is based in part on an old thread found elsewhere in this forum, concerning sending data to a PHP file by imitating the POST method:
    link:
    http://forum.java.sun.com/thread.jspa?threadID=530399&messageID=2603608
    someone named "harmmeijer" provided most of the answers on that thread. If that person is still around hope they take a look at this,also I have some questions to clarify what they said on the other thread..
    My first attempt at code is below. The applet is in a signed jar file and is trying to pass a text line to the PHP script in the same directory and on the same server that the applet came from. It is doing this by sending header information that is supposed to be identical to what an html form would send if it was uploading a .txt file with the line of text within it. The applet displays one button. When you press it, it sucessfully starts up the postsim method (defined at the end), which is supposed to send the info to the PHP script at the server.
    I have two questions:
    1) I know that the PHP script is starting up, because it prints out a few messages depending on what happens. However, the script does not recognize any file coming down the line, so it does not save anyting on the server, and prints out a message saying the no file was uploaded.
    Any idea what might be going wrong? I'm not getting any error messages from the applet. I've tried a few different variations of the 'header' information contained in the line:
    osToServer.writeBytes("--****4353\r\nContent-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    The commented out line below it shows one variation (which was given in the thread mentioned above).
    2) You'll notice that I've commented out the two lines having to do with the input line:
    //InputStream isFromServer;
    and
    //isFromServer = uc.getInputStream();
    The reason is that the program crahes whenever I put the latter line in - to the extent that Opera closes down the JVM and then crashes when I tried to exit it.. I must be doing something horribly wrong there! I first tried using isFromServer = new DataInputStream(uc.getInputStream());
    becuase it was consistent with the output stream, but that caused the same problem.
    Here's the code:
    public class AudioUptest1 extends Applet{
    //There are a few spurious things defined in this section, having to do with the fact the microphone data is evenuatly going to be sent. haven't yet insterted code to get input from a microphone.
    AudioFormat audioFormat;
    TargetDataLine targetDataLine;
    SourceDataLine sourceDataLine;
    DataOutputStream osToServer;
    //InputStream isFromServer;
    URLConnection uc;
    final JButton captureBtn = new JButton("Capture");
    final JPanel btnPanel = new JPanel();
    public void init(){
    System.out.println("Started the applet");
    try
    URL url = new URL( "http://www.mywebsite.com/handleapplet.php" );
    uc = url.openConnection();
    //Post multipart data
    uc.setDoOutput(true);
    uc.setDoInput(true);
    uc.setUseCaches(false);
    //set request headers
    uc.setRequestProperty("Connection", "Keep-Alive");
    uc.setRequestProperty("HTTP_REFERER", "http://applet.getcodebase");
    uc.setRequestProperty("Content-Type","multipart/form-data; boundary=****4353");
    osToServer = new DataOutputStream(uc.getOutputStream());
    //isFromServer = uc.getInputStream();
    catch(IOException e)
    System.out.println ("Error etc. etc.");
    return;
    //Start of GUI stuff
    captureBtn.setEnabled(true);
    //Register listeners
    captureBtn.addActionListener(
    new ActionListener(){
    public void actionPerformed(
    ActionEvent e){
    captureBtn.setEnabled(false);
    //Postsim method will send simulated POST to PHP script on server.
    postsim();
    }//end actionPerformed
    }//end ActionListener
    );//end addActionListener()
    add(captureBtn);
    add(btnPanel);
    // getContentPane().setLayout(new FlowLayout());
    // setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(250,70);
    setVisible(true);
    }//end of GUI stuff, constructor.
    //These buffers might be made larger.
    byte tempOutBuffer[] = new byte[100];
    byte tempInBuffer[] = new byte[100];
    private void postsim(){
    System.out.println("Got to the postsim method");
    try{
    //******The next four lines are supposed to imitate a POST upload from a form******
    osToServer.writeBytes("--****4353\r\nContent-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    //osToServer.writeBytes("Content-Disposition: form-data; name=\"testfile\"; filename=\"C:testfile.txt\"\r\nContent-Type: text/plain\r\n");
    //This is the text that's cupposed to be written into the file.
    osToServer.writeBytes("This is a test file");
    osToServer.writeBytes("--****4353--\r\n\r\n");
    osToServer.flush();
    osToServer.close();
    catch (Exception e) {
    System.out.println(e);
    System.out.println("did not sucessfully connect or write to server");
    System.exit(0);
    }//end catch
    }//end method postsim
    }//end AudioUp.java

    Hi All,
    I was trying to write a signed applet that helps the
    user of the applet to browse the local hard disk and
    select a file from the same. The JFileChooser class
    from Swing is what I used in my applet. The problem
    is with the policy file. I am not able to trace the
    exact way to write a policy file which gives a total
    access to read,write,delete,execute on all the drives
    of the local hard disk.
    I am successful in signing the applets and performing
    operations : read,write,delete & execute on a single
    file but failing to grant permission for the entire
    file.
    Any help would be highly appreciated.Which policy file are you using? there might be more than one policy file.
    also, u have to specify the alias of the signed certificate in the policy file to grant the necessary priviledges to the signed applet.

Maybe you are looking for