Selector in NIO notifies data to be read but bytes read 0

Hi All,
I am facing a problem in NIO which for which I have clue.
The selector object notifies that data is ready to be read from a particular channel after which
I execute the following to read the data into the buffer
readBuffer.clear();
int count = this.sockChannel.read(this.readBuffer);
The value of count which i get is 0 after which which i return without any processing
but this notification goes on and on as I can see in the logs which goes on logging
Count received as 0 infinitely.
Please help

There's a few things here.
1. I prefer to see only one read statement in these loops, like this:
while ((count = in.read(readBuffer)) > 0)
  readBuffer.flip();
  // get() from readBuffer into somewhere
// NB the 'len' to use is 'count'. You don't need to get it again via 'position()'.
// it generally makes more sense to use compact rather than clear() here
  readBuffer.compact();
}2. count < 0 doesn' t mean the socket is closed, it means the connection is closed. You have to close the socket, or the channel, yourself, and I don't see that:
if (count < 0)
  logger.debug("connection closed" ...); // etc
  in.close();
}3. You're testing bytes.length > 0 in a place where it can't possibly be zero.
4. I hope you're not really ignoring exceptions as shown. If you are, that would explain the behaviour completely - never do that. If you get any kind of an IOException in this code, the connection is hosed and you must log the exception and close the channel. The only exception to this rule is SocketTimeoutException, which doesn't happen in non-blocking mode.
5. Is there any possibility that the buffer is zero length? That would cause read() to return zero.

Similar Messages

  • Install Adobe Reader but cannot read PDF file

    Hi all,
    I am new and not familiar yet with forum so excuse me for a duplicate posting at
    http://www.adobeforums.com/webx/.59b65e89/6
    which is a thread "cannot install Adobe Reader". Since mine is a different problem, am transferring what I posted there into a new thread, which is as follows:
    ===============================
    I cannot read PDF files with web browser so uninstalled and reinstalled with Adobe Reader 9
    I still cannot read PDF file with web browser. After clicking on a link that is a link to a PDF file, I just get a blank page
    Why and what can I do?

    AOL used to have a lot of problems with PDFs, hope that has not returned. Anyway, the PDF was probably sent as a text file rather than encoded as a binary file. That would make it corrupt and is a problem on the senders end. Older versions of Outlook also had problems with PDFs that would cause a problem on your end.

  • FM or RFC to retrieve QM notification data

    Hi Gurus,
    I looking for a function that can fetch QM notification data from R/3, so that I can display the same in a WebDynpro application.
    I will be lucky if there is some standard FM to do that. If not, I have to do it my self for all the notification types we are using.
    The same with CS notifications too.
    Some one please suggest.
    Any help or suggestion will be of great help to me.
    Thank and regards,
    Chinnu

    Hi Avinash,
    Thank you, but i could not find the bapi.
    Hi Raymond,
    Thanks for the BAPIs. They helped me. Now, my next task is the update the notification data,
    I have found one BAPI for this purpose:
    BAPI_ALM_NOTIF_DATA_MODIFY
    Still have to test it with my code, hope it works fine. I am still looking at the BAPI fields to see if it contains all the fields i need. I will be gald if I can get some suggestions.
    Avinash and Raymond,
    Also, I have found one more BAPI to get the notification details:
    BAPI_ALM_NOTIF_GET_DATA.
    Plese let me know if i can use the BAPIs for reading and updating CS and QM notifications.
    Thanks and regards,
    Chinnu

  • Plugin check (incorrectly) says my acrobat plugin is out of date and takes me to a reader install

    Windows XP
    FF 20.0
    I have Adobe Acrobat X 10.1.6. and the plugin checker says its out of date.
    I don't think it is, it's just not Abobe Reader.
    I don't want to have both Acrobat and Reader. When I do, then there's two different plug-ins in FF, but they both have the same names, but they seem independent and it just seems messy. It looks as if the same plugin is on there twice, one updated and one not updated, but it doesn't seem possible to remove either one. Which is actually good, b/c one is for Acrobat and one is for Reader, which I didn't realize until I started looking into all this mess. Also, there's no point in me having Reader if I have Acrobat.
    It's weird that the plugin checker says the Acrobat plugin is out of date and directs me to the Reader 11 download to update it, eventhough I already have Reader 11 (thanks to the plugin checker). In other words, the one that is updated is Reader, but the one that is supposedly out of date just directs me to a DL that I already have installed. Sorry if its confusing.
    Now I downloaded it, and have since uninstalled it, but it seems well-known that there can be issues with dl'ing Reader when Acrobat is already uninstalled (or something), as well as when uninstalling one or the other, so now I am nervous, because I didn't take any precautionary measures when dl'ing or uninstalling Reader.
    I almost feel like I should uninstall everything (if possible) and just start fresh.
    Anyway, point is, the plugin checker is wrong, right?

    Hi jonadelman, if you have 10.1.6, you are current. It's just that the plugin checker doesn't know that both 10.1.6 and 11.0.2 are current.

  • As we are having a problem explicit with Adobe Reader 11.0.07, we are interested in news and dates for coming updates to Adobe Reader. Can I find information about this anywhere ?

    As we are having a problem explicit with Adobe Reader 11.0.07, we are interested in news and dates for coming updates to Adobe Reader. Can I find information about this anywhere ?

    Hello Claus,
    you could have a look here: http://helpx.adobe.com/security/products/flash-player/apsb14-13.html  and in german language http://www.chip.de/downloads/Adobe-Reader_12998358.html
    In all These cases Google could be "your friend".
    Hans-Günter

  • How can I change data on my XLS files? I have tried to open them in Adobe reader but they can't be read!!!

    Hi. I have problems changing the data on my XLS files.I tried Adobe reader but it can't open the files.What should I do??

    XLS are Microsoft Excel spreadsheet files.  You can use Microsoft Excel to open them... or any number of compatible applications (OpenOffice, Numbers, etc).

  • I am writing datas into a FIFO ,i am reading datas from fifo .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place .what is the reason ?

    I am writing datas into a FIFO in FPGA Target side  ,i am reading datas from fifo in windows host side  .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place, a(1) comes to a a(0) .what is the reason ?

    Please use a shorter title in your subject line and not post the entire question in therre.  (See the subject line I created.)   There is also no such word as "datas".  Data is already plural.
    Please read http://stackoverflow.com/help/how-to-ask.  Your question is hard to read because you aren't using proper punctuation and capitalization of your sentences.  It looks like one run-on sentence.
    Beyond that, it is impossible to help you solve our problem with just your question.  Please provide some more information.  Perhaps even attach code we can look at.  Show us what the data you are sending is supposed to look like, and what it actually looks like.

  • I'm using a 1D Arrary with 27 different elements and would like to send those data over UDP Write and UDP Read functions.

    I'm using a 1D array with 27 different elements. I would like to transfer that data over a UDP connection, and read it back by using UDP connections.
    But I would like to read 3 elements at a time (On read side) and send those to 9 different ports.
    Note: the data will go to only one PC with one Network Address)
    * 1st elements (0,1,2) and send to port #XXX to see those 1st 3 elements.
    * continue until the elements reaches up to 27
    This is what I have done but I'm finding myself in pitfalls...
    Send side:
    I'm using a UDP Open connection on send side to send my data. So with selected a Source Port, I have created a UDP Op
    en connection. I�m using only one source port to send all the data across the channel. I would like to read 1st 3 elements and send those data across with an assigned Destination port. I would like to do that for 9 times b/c there are 27 elements in the array. So I�m using a For Loop and setting N count to 9. So I�m not getting any errors when I execute and no answer on the other side at all.
    Read side:
    I�m using a UDP Open connection to read in the data with port #. I�m using while loop to with Boolean inside by making a true all the time. Inside that While loop, I�m using For Loop to read the 3 elements data a time and send to a right port address. (As start out I was just trying to see if it works for only one port).
    Attachments:
    UDP_SEND_1.vi ‏40 KB
    UDP_READ_1.vi ‏31 KB

    You are not getting any errors because UDP is a connectionless protocol. It does not care if anyone receives it. Your example will work fine with the following considerations.
    (1) Don't use the generic broadcast address (255.255.255.255).
    (2) You are listening on port 30000. So why are you sending to port 1502, nobody will receive anything there.
    The destination port of the outgoing connection must match the server port of the listener. (The source port is irrelevant, set ot to zero and the system will use a free ephemeral port).
    (3) On the receiving side, you are not indexing on the received string, thus you only retain the last received element. Then you place the indicator outside the while loop where it never gets updated. :-(
    (4) Do yourself a favor and don't micromanage how the data is sent across. Just take the entire array, flatten it to string, send it across, receive it, unflatten back to array, and get on with the task.
    (You can do the same with any kind of data).
    I have modified your VI with some reasonable default values (destination IP = 127.0.0.1 (localhost)), thus you can run both on the same PC for testing "as is". Just run the "read" first, then every time you run "send", new data will be received.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    UDP_READ_1MOD.vi ‏29 KB
    UDP_SEND_1MOD.vi ‏27 KB

  • Data Execution Prevention has closed Adobe Reader

    I cannot launch Adobe Reader, got the following message
    When I close program, a message says "Data Execution Prevention has closed Adobe Reader."  I have searched the Microsoft Community for fixes, but those suggestions don't work.
    I'm running Windows Vista Home Basic Version 6 Service Pack 2, 32 bit and I have downloaded Adobe Reader 10.1.4

    You can download the 10.1.9 update patch from http://www.adobe.com/support/downloads/detail.jsp?ftpID=5712
    Protected Mode is normally disabled from within Adobe Reader Preferences.  Since you cannot even open Adobe Reader, you can disable it via Windows registry: download, unzip, then run the attached registry script.

  • Incorrect data type when writing to FPGA Read/Write Control

    I have run in to a problem this morning that is causing me substantial headache.  I am programming a CompactRIO chassis running in FPGA mode (not using the scan engine) with LabVIEW 2012.  I am using the FPGA Read/Write Control function to pass data from the RT Host to the FPGA Target.  The data the RT host is sending comes from a Windows host machine (acting as the UI) and is received by the RT Host through a network published variable.
    The network published shared variable (shared between the RT and Windows system) is a Type Def cluster containing several elements, one of which is a Type Def cluster of fixed point numerics.  The RT system reads this shared variable and breaks out the individual elements to pass along to various controls on the FPGA code's front panel.  The FPGA's front panel contains a type def cluster (the same type def cluster, actually) of fixed point numerics.
    The problem comes in the RT code.  After I read the shared variable I unbundle the cluster by name, exposing the sub-cluster of fixed point numerics.  I then drop an FPGA Read/Write Control on the RT block diagram and wire up the FPGA reference.  I left click on the FPGA Read/Write Control and select the cluster of fixed point numerics.  I wire these together and get a coercion dot.  Being a coercion dot hater, I hover over it the dot and see that the wire data type is correct (type def cluster of fixed point numerics), but the terminal data type is listed as a cluster containing a Boolean, code integer and source string, also known as an error cluster.  I delete the wire and check the terminal data type on the Read/Write Control, which is now correctly listed as a type def cluster of fixed point numerics.  Rewiring it causes the terminal to revert back to the error cluster.  I delete the wire again and right click on the terminal to add a control.  Sure enough, a type def cluster of fixed point numerics appears.  Right clicking and adding an indicator to the unbundle attached to the network shared variable produces the proper result.  So, until they are attached to each other, everything works fine.  When I wire these two nodes together, one spontaneously changes to a error cluster.
    Any thoughts would be appreciated.

    My apologies I never got back to responding on this.  I regret that now because I got it to work but never posted how.  I ran in to the exact same problem today and returned to this post to read the fix.  It wasn't there, so I had to go through it all over again.
    The manifestation of the problem this time was that I was now reading from the Read/Write FPGA front panel control and writing to a network published shared variable.  Both of these (the published shared variable and the front panel control) were based on a strict type defined cluster, just like in the original post.  In this instance, it was a completely different cluster in a completely different project, so it was not a one-off thing.
    In addition to getting the coercion dot (one instance becoming an error cluster, recall), LabVIEW would completely explode this time around.  If I saved the VI after changing type definition (I was adding to the cluster) I would get the following error:
    Compile error.  Report this problem to N.I. Tech Support.  Copy cvt,csrc=0xFF
    LabVIEW would then crash hard and shutdown without completing the save.  FYI, I'm running LabVIEW 12.0f3 32-bit.
    If I would then reopen the RT code, the same crash would occur immediately, ad nauseam.  The only way to get the RT code to open was to change the type defined cluster back to the way it was (prior to adding the new element).
    I didn't realize it last time around (what originally prompted this post), but I believe I was adding to a type def cluster when this occurred the first time.
    So, how did I fix it this time around? By this point I tried many, many different things, so it is possible that something else fixed it.  However, I believe that all I had to do was to build the FPGA code that the RT code was referencing.  I didn't even have to deploy it or run it... I just had to build it.  My guess is that the problem was the FPGA Reference vi (needed to communicate with the FPGA) is configured (in my case) to reference a bit file.  When the development FPGA Main.vi ceases to match the bit file, I think that bad things happen.  LabVIEW seems to get confused because the FPGA Main.vi development code is up and shows the new changes (and hence has the updated type def), but when you ask the RT code to do something substantial (Open, Save, etc), it refers to the old bit file that has not yet been updated.  That is probably why the error getting thrown was a compile error.
    I'm going to have to do an additional round of changes, so I will test this theory.  Hopefully I will remember to update this post with either a confirmation or a retraction.

  • Reading 21576 bytes of data at offset 3 in a buffer of total size 114

    Logs claim it's a 'buffer overflow' - [2015-Jan-05 22:32:41] RDP (0): Exception caught: BufferOverflowException in file '../../gryps/misc/containers/flexbuffer.h' at line 421
    Specifics: 
    attempting to connect to virtual box running on localhost:55985
    OSX: 10.9.5
    RDP: 8.0.12
    VirtualBox: 4.3.20
    [2015-Jan-05 22:32:41] RDP (0): --- BEGIN INTERFACE LIST ---
    [2015-Jan-05 22:32:41] RDP (0): lo0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): lo0 af=30 (AF_INET6) addr=::1 netmask=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
    [2015-Jan-05 22:32:41] RDP (0): lo0 af=2 (AF_INET) addr=127.0.0.1 netmask=255.0.0.0
    [2015-Jan-05 22:32:41] RDP (0): lo0 af=30 (AF_INET6) addr=fe80::1%lo0 netmask=ffff:ffff:ffff:ffff::
    [2015-Jan-05 22:32:41] RDP (0): gif0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): stf0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): en0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): en0 af=30 (AF_INET6) addr=fe80::2acf:e9ff:fe1a:cc0d%en0 netmask=ffff:ffff:ffff:ffff::
    [2015-Jan-05 22:32:41] RDP (0): en0 af=2 (AF_INET) addr=192.168.10.108 netmask=255.255.255.0
    [2015-Jan-05 22:32:41] RDP (0): en4 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): en5 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): bridge0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): p2p0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): vboxnet0 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): vboxnet1 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): vboxnet2 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): vboxnet3 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): vboxnet4 af=18 addr= netmask=
    [2015-Jan-05 22:32:41] RDP (0): --- END INTERFACE LIST ---
    [2015-Jan-05 22:32:41] RDP (0): correlation id: 10b4ea14-964f-83df-bf55-4ff43fb10000
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to '127.0.0.1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to '::1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to 'fe80:1::1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Exception caught: BufferOverflowException in file '../../gryps/misc/containers/flexbuffer.h' at line 421
    User Message : Reading 12112 bytes of data at offset 3 in a buffer of total size 82
    [2015-Jan-05 22:32:41] RDP (0): correlation id: 10b4ea14-964f-83df-bf55-4ff43fb10000
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to '127.0.0.1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to '::1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Resolved 'localhost' to 'fe80:1::1' using NameResolveMethod_DNS(1)
    [2015-Jan-05 22:32:41] RDP (0): Exception caught: BufferOverflowException in file '../../gryps/misc/containers/flexbuffer.h' at line 421
    User Message : Reading 21576 bytes of data at offset 3 in a buffer of total size 114
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolConnectingNetwork(1)
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolNegotiatingCredentials(2)
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolConnectingNetwork(1)
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolNegotiatingCredentials(2)
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolDisconnecting(7)
    [2015-Jan-05 22:32:41] RDP (0): Protocol state changed to: ProtocolDisconnected(8)
    [2015-Jan-05 22:32:41] RDP (0): ------ END ACTIVE CONNECTION ------
    ps: the editor for posting on this forum is absolutely the most terrible I had ever seen.

    Hi,
    Please let us know which OS you are trying to connect. Because if you are running Windows 8 and not Windows 8 Pro then you won't be able to connect to your PC from any device. Windows 8 can't host an RDP session.  
    Remote Desktop Client on Mac: FAQ
    http://technet.microsoft.com/en-in/library/dn473006.aspx
    Hope it helps!
    Thanks.
    Dharmesh Solanki
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • How to convert data read in byte to decimal number?

    The following are a source code to read from a serial port, but i can't convert the data that i read to decimal number and write it on a text file.....can anyone kindly show me how to solve it? thanks
    import javax.comm.*;
    import java.io.*;
    import java.util.*;
    public class Read implements Runnable, SerialPortEventListener {
         // Attributes for Serial Communication
         static Enumeration portList;
         static CommPortIdentifier portId;
         SerialPort serialPort;
         static OutputStream outputStream;
         InputStream inputStream;
         Thread readThread;
         public static void main(String s[])
         portList=CommPortIdentifier.getPortIdentifiers();
         while(portList.hasMoreElements())
              portId=(CommPortIdentifier)portList.nextElement();
              if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL)
                   if(portId.getName().equals("COM1"))
                        System.out.println( portId.getName());
                        Read ss=new Read();
              }     // end of while
    }          // end of main
    public Read()     {
    try{
              serialPort=(SerialPort)portId.open("Read", 2000);
    catch(PortInUseException e)     {}
         try{
              inputStream=serialPort.getInputStream();
              System.out.println(inputStream);
    catch(IOException e)     {}
         try{
              serialPort.addEventListener(this);
    catch(Exception e)     {}
              serialPort.notifyOnDataAvailable(true);
         try{
              serialPort.setSerialPortParams(9600,
              SerialPort.DATABITS_8,
              SerialPort.STOPBITS_1,
              SerialPort.PARITY_NONE);
              }catch(UnsupportedCommOperationException e)     {}
              readThread=new Thread(this);
              readThread.start();
         }//end of constructor
         public void run()
              try     {
                   Thread.sleep(200);
              }catch(InterruptedException e)     {}
         public void serialEvent(SerialPortEvent event)
              switch(event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                   break;
                   case SerialPortEvent.DATA_AVAILABLE:
                   byte[]readBuffer=new byte[8];
                   try{
                        while(inputStream.available()>0)
                             int numBytes=inputStream.read(readBuffer);
                             //System.out.println("hello");
                        System.out.print(new String(readBuffer));
                        }catch(IOException e)     {}
                   break;
                   }     // end of switch
                   try     {
                        inputStream.close();
                        }catch(Exception e5)     {}
         }          // end of serialEvent

    Is it a float or a double?
    For a float, the decimal should be 4 bytes (small numbers like 1.1 start with the byte 0x40). Convert these 4 bytes to an int, using byte-shifting would probably be easiest.
    int value = ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);//b# are bytesNow to convert it to a float, use
    Float.intBitsToFloat(value);Now if you want double percision, You will have 8 bytes instead of 4, and need to be converted to a long instead of an int through byte-shifting. Then use Double.longBitsToDouble(long bits) to get the double

  • Email - how do i get notification that a sent email has been read

    Hi
    I am using OSX 10.9.5 and mail version 7.3.
    How can I get notification on a particular email that it has been read/opened by the recipient?
    Many thanks

    Read Receipts
    Read Receipts (2)
    Read Receipts - Answer

  • How do I resolve the "insufficient data for image" error for Adobe reader 11.0.04?

    How do I resolve the "insufficient data for image" error for Adobe reader 11.0.04?

    Hi Johnkel1524,
    Please refer : http://helpx.adobe.com/acrobat/kb/insufficient-data-image.html
    Also try updating to 11.0.5 and check.

  • TCP Read w/ #bytes=4 returns wrong data.

    On an initial TCP Read to a just-open connection, I can read any number of bytes, always getting the first n bytes from the arriving data. Except when I try to read 4 bytes! Then I get 4 bytes, but they're the seventh through ninth bytes, not the first four. Haven't found any other number that gives problems - 1,2,3,5,6,7,8,16,40,1020,etc. all work fine. Ideas?

    You may want to try runnig the Data Client and Data Server example VIs which ship with LabVIEW and see if they work on your system. The Client example actually reads in 4 bytes every time. I ran it and it works fine, so if yours exhibits the behavior you've been seeing, then the problem could be with your connection. Otherwise, if the example does work, then it could be somewhere in your code. Let us know what you find.
    J.R. Allen

Maybe you are looking for