Problems with Buffered Read() - write() cycle

URGENT!!!
I have two network hosts communicating through Socket.
i need a cycle of read/write until an escape string is written ("QUIT").
BUT after first readLine() it stucks on blocking method, doesn't read anything!
why?
so my code look like this (i cut out initialization and boring parts):
BufferedReader input;
BufferedWriter output;
String readString = "";
while(read!="QUIT") {
output.write("mySentence");
readString = input.readLine();
}THANKS

you are all right, but I do use newLine() just to have the line separator.
the exception is always the same (this afternoon it didn't result in an exception... ):
java.net.SocketException: Software caused connection abort: recv failedI really can't figure it out...
moreover, I don't understand which side generates the problem, since one side is an Applet.
Again, the curious thing is that before the cycle they read and write (just once) normally!
I post the actual part of the code, in order not to create misunderstandings...
of course I used EITHER the "\n" OR the newLine() but not togheter...
server side the method is called within a thread class...
APPLET:
do     {
       String letto = listaParametri.poll();
         os.write(letto);
        os.newLine();
        while( !letto.equals("LAST") );
os.flush();
while( this.isActive() )     {
             received = is.readLine();
           if     ( received.equals("CHANGE") )
                          getAppletContext().showDocument(reloadURL, "_main");
                          break;
           else     if( received.equals("ALIVE") )     
                         {                               os.write("YES\n");
                           os.newLine();
                           os.flush();
                                              }SERVER:
while(!CLOSED)
                                     {if(CHANGE)     {
                                                     outputStream.write("CHANGE");
                                                     outputStream.close();
                                                     System.out.println("sent RELOAD comand - now Closed - );
                                                     break;
                                     else     {
                                                outputStream.write("ALIVE\n");
                                                //outputStream.newLine();
                                               outputStream.flush();
                                                    System.out.println("inputStream");
                                               appletStatus = inputStream.readLine();
                                                    System.out.println(" - appletStatus=" + appletStatus);
                                               if( appletStatus == null )               CLOSED = true;
                                     else     if( appletStatus.equals("YES") )     CLOSED = false;

Similar Messages

  • Problems with buffered reads, buffers

    I have a few questions and issues that I have not been able to resolve with forum searches, I will try to keep them concise here.  #1 is the most important one to me.
    LabVIEW 7.1, Windows XP.
    Buffered Reads / Lost Data
    When error 10846 (AI Buffered Read, app unable to retrieve data from background acquisition buffer fast enough) occurs, I receive no data from the AI Buffered Read function for a period of time.  The error states data may be lost but it seems like I get NO data.  See the attached VI and JPG for examples.  The bottom graph shows a normal read while the top graph shows one with this problem.  I realize the AI Read error cluster is not handled in the acquisition loop.  From watching the backlog while the program runs, it seems the “dead spots” occur after the backlog reaches the buffer size.  When stopping acquisition, sometimes the error handler outside the loop reports 10846, sometimes it doesn’t (when the dead spots are occurring).  I can exaggerate dead spots with setups as follows:
      Buffer size 5, Scan rate 1000, # Scans to read 100
      Buffer size 10000, Scan rate 5500, # Scans to read 100
    The size of the dead spots and continuous data are proportional to the buffer size.
    Questions....
    1. Shouldn’t the AI Read function wait until it has # scans to read of valid data before returning?  For instance, scan rate of 100 and # scans to read of 1000 slows loop iteration speed to 0.1 Hz.  It seems like it is returning nothing for a period of time after the backlog reaches the buffer size.
    2. Error 10846 refers to the “data acquisition buffer.”  Is this the software buffer?  If so, what would LV refer to the hardware buffer as?
    3. I know the PCI-MIO-16E-1 has a hardware buffer, does this mean I can accurately acquire data over a period of time at a specified frequency (within limitations of the card of course) without having to worry about Windows bogging down due to delayed writes and such?
    4. Will hardware acquisition buffers generate an error if the data in them is lost/overwritten?
    5. I tried loading the acquisition VI (attached) onto a LV computer that has only a new USB-6008 connected but the AI read/config/clear functions were not available on that system.  Does this device not have hardware buffers (either I’m looking in the wrong places to find the answer this question and it uses different VIs OR it doesn’t have them). 
    6. The buffer/scan configuration listed above was used to exaggerate error 10846 and the accompanying dead spots but this problem has been intermittently plaguing a system I have been trying to understand/fix.  I have logged the backlog value as the program runs and see that it increases during certain processor-heavy state machine states and am hoping upgrading from 256MB to 2GB RAM will improve this.  Is there any reason I should not look at this as a solution?  (I am also planning on adding an error handler for AI Read into each acquisition loop so the problem can not continue to go on without detection!!!!!!!!!)
    7. Shouldn’t the AI Clear function report an error from the AI Read error cluster, even if it happened several reads earlier?  It seems like it does not do this; if I put the error handler in the acquisition loop I receive an error as soon as the backlog reaches the buffer size, EVERY time.  I thought I figured this out and changed the acquisition loop tunnels to shift registers... the error is reported each time this way; if AI Read will not acquire data if an error is fed into it in the first place then I guess I understand this one so I’m moving it to the bottom of the list.
    Thank you all for your time, I have been struggling to get up to speed with DAQ and LV and appreciate all the support.  I look forward to giving back to NI’s community in the future. 
    Regards,
    David.

    After all that typing I forgot the attachements, they should be on this post.
    I take it the AI.llb functions are "traditional DAQ."  I've started to experiment with the express VIs with newer hardware that I have been working with (USB-6008, USB-6211).  I will have to look at the DAQmx functions, it seems the express VIs are frowned upon by most.
    I have been working on modifying an older program that uses the traditional DAQ functions.  I will have to get more comfortable with DAQmx before attempting to change it over to them.  The attached example was wrote as I tried to understand what was going on in the program I was modifying.
    I believe the missing error handler on the AI Read function was causing unexpected (i.e. nothing returned) results the next time AI Read was called when the backlog exceeded the buffer value.  Subsequent calls to AI Read worked as expected unless the buffer overflowed again.
    Assuming this is correct the hardware buffer is the only thing I would like to understand better.  If it overflows what error (if any) will be generated in LV? 
    The other questions can be chalked up to the way traditional DAQ functions work and I think I've chased my tail enough to figure that out.
    Thanks,
    David.
    Attachments:
    acquire.jpg ‏25 KB
    acquire.vi ‏293 KB

  • Problem with ImageIO.read and ImageReader JPG colors are distorted/wrong

    (Using JDK 1.5)
    ImageIO incorrectly reads some jpg images.
    I have a jpg image that, when read by the ImageIO api, all the colors become reddish.
            try
                java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read( new java.io.File("javabug.jpg") );
                javax.imageio.ImageIO.write( bi, "jpg", new java.io.File("badcolors.jpg") );
                javax.imageio.ImageIO.write( bi, "png", new java.io.File("badcolors.png") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }Why is this happening??? My guess is there is a problem with the ImageIO.read ?
    the jpg can be downloaded at http://www.alwaysvip.com/javabug.jpg
    <BufferedImage@11faace: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1ebbfde transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1691 height = 1269 #numDataElements 3 dataOff[0] = 2>
    I have even tried creating a new buffered image but still have the same problem:
    (suggested by http://forum.java.sun.com/thread.jspa?forumID=20&threadID=665585) "Java Forums - ImageIO: scaling and then saving to JPEG yields wrong colors"
            try
                java.awt.image.BufferedImage bi = javax.imageio.ImageIO.read( new java.io.File("javabug.jpg") );
                java.awt.image.BufferedImage out = new java.awt.image.BufferedImage( bi.getWidth(), bi.getHeight(), java.awt.image.BufferedImage.TYPE_INT_RGB );
                java.awt.Graphics2D g = out.createGraphics();
                g.drawRenderedImage(bi, null);
                g.dispose();
                javax.imageio.ImageIO.write( out, "jpg", new java.io.File("badcolors.jpg") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }I have used the following which works but does not use the ImageIO api. However, I tried using the ImageIO to write and it worked for writing which leads me to believe there is a problem with the reader.
    (suggested by http://developers.sun.com/solaris/tech_topics/java/articles/awt.html "Server-Side AWT")
            try
                java.awt.Image image = new javax.swing.ImageIcon(java.awt.Toolkit.getDefaultToolkit().getImage("javabug.jpg")).getImage();
                java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage( image.getWidth( null ), image.getHeight( null ), java.awt.image.BufferedImage.TYPE_INT_RGB );
                java.awt.Graphics g = bufferedImage.createGraphics();
                g.setColor( java.awt.Color.white );
                g.fillRect( 0, 0, image.getWidth( null ), image.getHeight( null ) );
                g.drawImage( image, 0, 0, null );
                g.dispose();
                com.sun.image.codec.jpeg.JPEGImageEncoder encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder( new java.io.FileOutputStream( "goodcolors.jpg" ) );
                encoder.encode( bufferedImage );
                javax.imageio.ImageIO.write( bufferedImage, "jpg", new java.io.File("goodiocolors.jpg") );
                javax.imageio.ImageIO.write( bufferedImage, "png", new java.io.File("goodiocolors.png") );
            catch ( java.io.IOException ioe )
                ioe.printStackTrace();
            }BTW, the following does not work either:
                java.util.Iterator readers = javax.imageio.ImageIO.getImageReadersByFormatName( "jpg" );
                javax.imageio.ImageReader reader = ( javax.imageio.ImageReader ) readers.next();
                javax.imageio.stream.ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream( new java.io.File("javabug.jpg") );
                reader.setInput( iis, true );
                java.awt.image.BufferedImage bufferedImage = reader.read( 0 );

    I figured out the problem. It was an actual BUG in the JDK!
    The code failed with the following JDKs:
    java version "1.5.0_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
    Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
    java version "1.5.0_03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
    Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
    The code ran sucessful with this JDK:
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
    If you are using the ImageIO classes, I highly suggest you upgrade to the latest JDK.
    Best,
    Scott

  • Problem with Adobe Reader not being able to run with Maverick  10.9.2?

    problem with Adobe Reader not being able to run with Maverick  10.9.2?

    Have you updated your version of Adobe Reader?

  • Problem with adobe reader, commenting

    one of our authors is using adobe reader x 11,1, and I send him a pdf (enabled commenting and measuring), but for some reason the commenting-fields does not show on his screen?
    should I save the pdf in another way?

    What do you mean by "commenting fields" exactly? By “commenting filds” I mean the tools in top of the page – delete, highlight etc. When I send the pdf, I save it as “file - save as -  reader extended pdf – enable commenting and measuring”, otherwise the commenting tools normally don’t appear by the author.
    Are they existing comments? no, it is the text in his pdf-book he needs to correct
    Is he able to access the commenting tools? no
    You can try sending a non-enabled version since Reader 11 can add comments to a non-enabled document. will try that J
    Fra: George Johnson [email protected]
    Sendt: 6. november 2012 16:16
    Til: Forlagene Idag & Nordan
    Emne: problem with adobe reader, commenting
    Re: problem with adobe reader, commenting
    created by George Johnson <http://forums.adobe.com/people/George_Johnson>  in Creating, Editing & Exporting PDFs - View the full discussion <http://forums.adobe.com/message/4826849#4826849

  • Continued problems with Adobe Reader 9.3.1

    Adobe Reader stops at the half-way mark in the progress block when loading a form to print.  Cannot get this fixed. Does anyone out there have a fix for this.  Is Adobe even recognizing that there is a problem with this.  Error message keeps telling me that there is a problem with Adobe Reader, exit and try again.

    I haven't been able to print any .pdf files since I downloaded 9.3.
    My message says Internet Explorer has closed it down because of data executable files.  I've changed my DEF settings to allow
    Adobe Reader but it still doesn't work.  I never had any problems before with newer versions.

  • Having problem with adobe reader

    Hi,
    I have a problem with adobe reader in my cell phone E71 model recently.I could open any pdf files till yesterday,but now without any reason the adobe reader icon in the office folder does not open.I wanna know what should I do.

    Might be some problem with adobe reader. You may Google another pdf app called pdf plus. Install it and see if the problem is solved or not.
    Nokia C7

  • Finding exception with the read-write-backing-map-scheme configuration.

    Finding exception with the <read-write-backing-map-scheme> configuration, that is setup against a simple database cache store implementation. The class SimpleCacheEventStoreImpl implements CacheStore interface.
    Exception in thread "main" java.lang.UnsupportedOperationException: configureCache: read-write-backing-map-scheme
         at com.tangosol.net.DefaultConfigurableCacheFactory.configureCache(DefaultConfigurableCacheFactory.java:995)
         at com.tangosol.net.DefaultConfigurableCacheFactory.ensureCache(DefaultConfigurableCacheFactory.java:277)
         at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:689)
         at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:667)
         at Sample.SimpleEventStoreConsumer.main(SimpleEventStoreConsumer.java:10)
    The cache store is interfaced to the program SimpleEventStoreConsumer(where I have a put and get operation) through the following cache configuration descriptor. On running the SimpleEventStoreConsumer, the exception happens on trying to get the Named cache from the cache factory
    <cache-config>
         <caching-scheme-mapping>
              <cache-mapping>
                   <cache-name>Evt*</cache-name>
                   <scheme-name>SampleDatabaseScheme</scheme-name>
              </cache-mapping>
         </caching-scheme-mapping>
         <caching-schemes>
              <read-write-backing-map-scheme>
                   <scheme-name>SampleDatabaseScheme</scheme-name>
                   <internal-cache-scheme>
                        <local-scheme>
                             <scheme-ref>SampleMemoryScheme</scheme-ref>
                        </local-scheme>
                   </internal-cache-scheme>
                   <cachestore-scheme>
                        <class-scheme>
                             <class-name>com.emc.srm.cachestore.SimpleCacheEventStoreImpl</class-name>
                             <init-params>
                                  <init-param>
                                       <param-type>java.lang.String</param-type>
                                       <param-value>{cache-name}</param-value>
                                  </init-param>
                             </init-params>
                        </class-scheme>
                   </cachestore-scheme>
              </read-write-backing-map-scheme>
              <local-scheme>
                   <scheme-name>SampleMemoryScheme</scheme-name>
              </local-scheme>
         </caching-schemes>
    </cache-config>

    you are missing <backing-map-scheme>. Do like following:
    <caching-schemes>
              <distributed-scheme>
                   <scheme-name>distributed-scheme</scheme-name>
                   <service-name>DistributedQueryCache</service-name>
                   <backing-map-scheme>
                        <read-write-backing-map-scheme>
                             <scheme-ref>rw-bm</scheme-ref>
                        </read-write-backing-map-scheme>
                   </backing-map-scheme>
    <autostart>true</autostart>
              </distributed-scheme>
              <read-write-backing-map-scheme>
                   <scheme-name>rw-bm</scheme-name>
    <internal-cache-scheme>
         <local-scheme>
                        </local-scheme>
                   </internal-cache-scheme>               
              </read-write-backing-map-scheme>
    </caching-schemes>

  • Problems with flash reader, flash reader

    problems with flash reader, flash reader

    flash reader is an App for iPhone, iPad and iPod. Do you mean Flash Player?
    And, what is the problem?

  • Trying to open PDF getting error message " there is a problem with Acrabat /Reader. Please exit Adob

    I have windows XP, when I am trying open PDF getting a error message " there is a problem with Acrabot /Reader. Please exit Adobe Acrabat/Reader Please try again'  It was working earlier today  HELP

    If all else fails, you can try one of 2 things (I will assume you are talking about Reader - though this is not the Reader forum). Use ctrl-alt-del to go to the task list. Kill AcroRd32.exe. Then try again. If that does not work, a reboot will probably solve the problem.

  • How to run duplicate fields with different read/write capability

    Hello,
    I'm trying to figure out how to have 2 identical fields but with different read / write capabilities.  For example:
    I have a document that has a policy number in textfield1 in the application.  I also have a page footer textfield2 that is identically named as textfield1.  I want the customer to be able to enter their policy number in textfield1, but then i want textfield2 to show that same information but remain locked and read-only.
    How can I best accomplish this?
    Thanks,
    Ryan.

    Hi,
    This doesn't seem to work.
    My field names are policy_number and policy_number2.
    I have entered this script into the field validation for policy_number2.
    event.value = this.getField("policy_number").value;
    It's showing blank in the policy_number2 field.
    Ryan.

  • Problem With File Reading And Sorting

    I'm having problems with a particular task. Here is what I have to do:
    Write a program which reads 100 integers from a file. Store these integers
    in an array in the order in whcih they are read. Print them to the screen.
    Sort the integers in place using bubble sort. Print the sorted array to the
    screen. Now implement the sieve of Eratosthenes to place all prime numbers
    in an ArrayList. Print that list to the screen.
    Here is the code I have so far:
    import java.util.ArrayList;
    import java.io.*;
    public class Eratosthenes
        private ArrayList numbers;
        private String inputfile1 = "numbers.txt";
        public Eratosthenes()
            numbers = new ArrayList();
        public void readData()
            try {
                BufferedReader reader = new BufferedReader(new FileReader(inputfile1));
                for(int i = 1; i <= 100; i++) {
                    String temp = reader.readLine();
                    numbers.add();
            catch(Exception e)
    This is the file reading part I have done but it doesn't recognise the line numbers.add() . It brings up the error - 'Cannot resolve symbol - method add(). Thats the first problem I have, can anyone see any way to fix it and to achieve the task. Also can someone help with the structure of a bubble sort method and a sieve of Eratosthenes method as I have no clue whatsoever. Any help will be greatly appreciated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Ok, I've done that but I'm having another problem. When I'm printing an output to the screen, it prints 100 lines of integers and not 1 line of 100 integers. Can you see the problem in the code that is doing this?
    import java.util.ArrayList;
    import java.io.*;
    public class Eratosthenes
        private ArrayList numbers;
        private String inputfile1 = "numbers.txt";
        public Eratosthenes()
            numbers = new ArrayList();
        public void readData()
            try {
                BufferedReader reader = new BufferedReader(new FileReader(inputfile1));
                for(int i = 1; i <= 100; i++) {
                    String temp = reader.readLine();
                    numbers.add(temp);
                    System.out.println(numbers);
            catch(Exception e)
    }

  • Problem with Connection Itunes writes "Ichat Icons"

    Why i connect my Iphone 5 to ITunes, and the ITunes can not connect the Phone and writes" Itunes cannot sync photos to the iPhone because you do not have write access to the folder" Ichat Icons"??

    lots of people having the exact same problem with the new update.
    Apple does not seem to care -- there is no fix at this time.
    Best thing to do it keep calling them.

  • Problems using AVI read/write example

    I would like to test some vision processing software I wrote by reading an AVI file rather than a live stream. I found the "AVI read/write example" mentioned on this forum and it sounds like exactly what i need, but I cannot get it to read my avi files. When I run the example read VI, it says "An exception occured with the external code called by a call library node". Doing further testing, I found one AVI on my computer that would work, all others crash the VI. Another odd behavior is that the "avi init read" subvi will return the wrong frame rate for some AVIs. I have tried both compressed and uncompressed AVIs all in RGB format. I have also tried different frame rates and encoding options for my AVI file with no luck. I am just a stud
    ent, so buying software is not an option for me.
    Has anyone had problems reading AVIs with this? Are there AVI encoding options that will make this VI work?

    Hello,
    I think the avi functions that you get are VFW based, it can not read
    any format of compression codec. But it should be able to read
    uncompressed AVI files. But anyway, if you can't get IMAQ-vision 7.0
    avi functions to try (I don't have, I don't know how it works), you
    can always get my IVision to try out. In IVision, there are two groups
    of avi functions. One is called "AVI functions", they are VFW based,
    so not always work for all kind compressed avi files, but I have
    another group called "Media files", the functions there work for all
    format compressed AVI files, including mpeg, asf, avi... you can
    access the frame image by using a callback vi (example included), seek
    the media position, change play rate, etc.
    Go to get a download at:
    http://www.hytekautomatio
    n.com/Products/IVision.html
    Irene
    excube wrote in message news:<50650000000800000028B00000-1068850981000@exc​hange.ni.com>...
    > I would like to test some vision processing software I wrote by
    > reading an AVI file rather than a live stream. I found the "AVI
    > read/write example" mentioned on this forum and it sounds like exactly
    > what i need, but I cannot get it to read my avi files. When I run the
    > example read VI, it says "An exception occured with the external code
    > called by a call library node". Doing further testing, I found one AVI
    > on my computer that would work, all others crash the VI. Another odd
    > behavior is that the "avi init read" subvi will return the wrong frame
    > rate for some AVIs. I have tried both compressed and uncompressed AVIs
    > all in RGB format. I have also tried different frame rates and
    > encoding options for my AVI file with no luck. I am just a student, so
    > buying software is not an option for me.
    >
    > Has anyone had problems reading AVIs
    with this? Are there AVI encoding
    > options that will make this VI work?

  • ICalExternalSync locks up my system with disk read/writes -  any fixes?

    When I allow ICalExternalSync to run it completely hangs up my system by hogging a gig of real memory and nearly 3 gigs of virtual memory. It also floods the system with continuous disk read/writes - which stop immediately when I quit the process.
    I've learned to shut ICalExternalSync down in "Activity Monitor" as soon as I've synced my calenders.
    Anyone else have this problem and a fix?

    I thought so too, but after doing that, the total download size for the updates was bigger than the space left. It was 2.8 gigs of downloads, and the root partition was 5.6 gigs full out of 7.56 gigs.
    I've never experienced such a huge update before! It's been a few hours and i'm still fixing it. There's literally hundreds of thousands of files that are now giving me "file exists in filesystem" errors so i'm making a script to delete all of those.
    To get an idea of how many files there was, i outputted the errors to a file, opened it up with less, then pressed and held page down for almost 2 minutes, didn't reach the bottom, so ended up just pressing end.
    Anyways, I'm going to post the scripts so it in case anyone encounters this critical problem, they can follow some simple instructions and be on their way.

Maybe you are looking for