Io vs. nio

I am new to Java but have been writing VC++ for years. My first project in Java is to write a small file sync program that will be installed on a handful of servers. I want to use sockets to pass the files back and forth over a socket, but I am not if I should use io or nio.
We are talking only a handful of simultaneous connections, but I am weary of sockets on Windows because of problems I have seen with winSock.
Thoughts? Do those winsock problems exist for Java sockets also?
Many thanks in advance!

the "problems" with winsock are almost universally due to people making stupid mistakes when using it.
That's no different from any networking library (or any other API, though networking stuff suffers from it more than some).
And yes, NIO is IO, just "new and improved" :)
Both use IP networking under the hood, which on Windows calls the Windows IP stack which means Winsock (if you insist on using that old name which AFAIK isn't in Schwung anymore in Redmond).

Similar Messages

  • Mysterious Teardown Problem with NIO

    I have an NIO proxy server which relays state information from a number of servers to a number of clients. A requirement for this system is that we can restart the proxy server (together with a couple of other components) from a web app.
    I tear down the proxy server by
    - interrupting out of the read loop
    - cancelling all keys associated with the channel
    - closing the socket on the channel
    - closing the channel.
    I do this for for both the input (server side) channel and the output (client side) channel.
    I then discard the proxy server, create a new one and start it up.
    Now here's the mysterious bit. The new server operates just fine for a minute or two. And then it stops seeing any input.
    The thread responsible for input reading freezes on the call to -
    myKeysAdded = myAcceptKey.selector().select();and the stack looks something like this:
    WindowsSelectorImpl$SubSelector.poll0(long, int, int[], int[], int[], long)
    WindowsSelectorImpl$SubSelector.poll() line: 270
    WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl$SubSelector) line: 252
    WindowsSelectorImpl.doSelect(long) line: 133
    WindowsSelectorImpl(SelectorImpl).lockAndDoSelect(long) line: 69
    WindowsSelectorImpl(SelectorImpl).select(long) line: 80
    WindowsSelectorImpl(SelectorImpl).select() line: 84
    ProxyServer$BrowserSelector.run() line: 123If I completely destroy the process (and the jvm) and start a new one everything goes back to working normally.
    Has anyone got any suggestions? I'm in hair-tearing mode on this one.
    Thx TOTW.

    I tear down the proxy server by
    - interrupting out of the read loopDon't you mean the select() loop?
    - cancelling all keys associated with the channelUnnecessary.
    - closing the socket on the channel
    - closing the channel.Only one of these is necessary. Closing the socket closes the channel and vice versa.
    When you have closed all the channels, you then need to call selector.selectNow() (search this forum for why), and then close the selector.

  • Java.nio select() method return 0 in my client application

    Hello,
    I'm developing a simple chat application who echo messages
    But my client application loop because the select() method return 0
    This is my code
    // SERVER
    package test;
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.ServerSocketChannel;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    import java.util.Set;
    public class Server {
         private int port = 5001;
         public void work() {               
              try {
                   ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
                   serverSocketChannel.configureBlocking(false);
                   InetSocketAddress isa = new InetSocketAddress(port);               
                   serverSocketChannel.socket().bind(isa);
                   Selector selector = Selector.open();
                   serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
                   System.out.println("Listing on "+port);
                   while(selector.select()>0) {
                        Set keys = selector.selectedKeys();
                        for(Iterator i = keys.iterator(); i.hasNext();) {
                             SelectionKey key = (SelectionKey) i.next();
                             i.remove();
                             if (key.isAcceptable()) {
                                  ServerSocketChannel keyChannel = (ServerSocketChannel)key.channel();                              
                                  SocketChannel channel = keyChannel.accept();
                                  channel.configureBlocking(false);                              
                                  channel.register(selector, SelectionKey.OP_READ );
                             } else if (key.isReadable()) {
                                  SocketChannel keyChannel = (SocketChannel) key.channel();
                                  String m = Help.read(keyChannel );
                                  Help.write(m.toUpperCase(), keyChannel );
              } catch (IOException e) {                                             
                   e.printStackTrace();                         
         public static void main(String[] args) {
              Server s = new Server();
              s.work();
    // CLIENT
    package test;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    import java.util.Set;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class Client extends JFrame  {
         private String host = "localhost";
         private int port = 5001;
         private SocketChannel socketChannel;
         private Selector selector;
         public void work() {               
              try {
                   socketChannel = SocketChannel.open();
                   socketChannel.configureBlocking(false);
                   InetSocketAddress isa = new InetSocketAddress(host, port);               
                   socketChannel.connect(isa);
                   selector = Selector.open();
                   socketChannel.register(selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ );
                   while(true) {
                        selector.select();
                        Set keys = selector.selectedKeys();
                        for(Iterator i = keys.iterator(); i.hasNext();) {
                             SelectionKey key = (SelectionKey) i.next();
                             i.remove();
                             if (key.isConnectable()) {
                                  SocketChannel keyChannel = (SocketChannel) key.channel();
                                  if (keyChannel.isConnectionPending()) {
                                       System.out.println("Connected "+keyChannel.finishConnect());                                                                           
                             } else if (key.isReadable()) {                                                                                                                                                           
                                  SocketChannel keyChannel = (SocketChannel) key.channel();                                             
                                  String m = Help.read(keyChannel);
                                  display(m);                                                                                                                                                                                                                   
              } catch (IOException e) {                                             
                   e.printStackTrace();                         
         private void display(final String m) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        area.append(m+"\n");
                        textFieed.setText("");
         private void sendMessage(final String m) {
              Thread t = new Thread(new Runnable() {               
                   public void run() {                                                                                
                        try {                         
                             Help.write(m, socketChannel);
                        } catch (IOException e) {               
                             e.printStackTrace();
              t.start();                    
         public Client() {
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(1);
              textFieed.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode()== KeyEvent.VK_ENTER) {
                             String m = textFieed.getText();
                             sendMessage(m);     
              area.setEditable(false);
              getContentPane().add(textFieed, "North");
              getContentPane().add(new JScrollPane(area));
              setBounds(200, 200, 400, 300);
              show();
         private String messageToSend;
         private JTextArea area = new JTextArea();
         JTextField textFieed = new JTextField();
         public static void main(String[] args) {
              Client s = new Client();
              s.work();
    // HELPER CLASS
    package test;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    import java.nio.CharBuffer;
    import java.nio.channels.SocketChannel;
    import java.nio.charset.Charset;
    import java.nio.charset.CharsetDecoder;
    import java.nio.charset.CharsetEncoder;
    public class Help {
         private static Charset charset = Charset.forName("us-ascii");
         private static CharsetEncoder enc = charset.newEncoder();
         private static CharsetDecoder dec = charset.newDecoder();
         private static void log(String m) {
              System.out.println(m);
         public static String read(SocketChannel channel) throws IOException {
              log("*** start READ");                              
              int n;
              ByteBuffer buffer = ByteBuffer.allocate(1024);
              while((n = channel.read(buffer)) > 0) {
                   System.out.println("     adding "+n+" bytes");
              log("  BUFFER REMPLI : "+buffer);
              buffer.flip();               
              CharBuffer cb = dec.decode(buffer);          
              log("  CHARBUFFER : "+cb);
              String m = cb.toString();
              log("  MESSAGE : "+m);          
              log("*** end READ");
              //buffer.clear();
              return m;                    
         public static void write(String m, SocketChannel channel) throws IOException {          
              log("xxx start WRITE");          
              CharBuffer cb = CharBuffer.wrap(m);
              log("  CHARBUFFER : "+cb);          
              ByteBuffer  buffer = enc.encode(cb);
              log("  BUFFER ALLOUE REMPLI : "+buffer);
              int n;
              while(buffer.hasRemaining()) {
                   n = channel.write(buffer);                         
              System.out.println("  REMAINING : "+buffer.hasRemaining());
              log("xxx end WRITE");

    Here's the fix for that old problem. Change the work method to do the following
    - don't register interest in things that can't happen
    - when you connect register based on whether the connection is complete or pending.
    - add the OP_READ interest once the connection is complete.
    This doesn't fix all the other problems this code will have,
    eg.
    - what happens if a write is incomplete?
    - why does my code loop if I add OP_WRITE interest?
    - why does my interestOps or register method block?
    For code that answers all those questions see my obese post Taming the NIO Circus
    Here's the fixed up Client code
    // CLIENT
    package test
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    import java.util.Set;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    public class Client extends JFrame  {
         private String host = "localhost";
         private int port = 5001;
         private SocketChannel socketChannel;
         private Selector selector;
         public void work() {
              try {
                   socketChannel = SocketChannel.open();
                   socketChannel.configureBlocking(false);
                   InetSocketAddress isa = new InetSocketAddress(host, port);
                   socketChannel.connect(isa);
                   selector = Selector.open();
                   int interest = 0;
                   if(socketChannel.isConnected())interest = SelectionKey.OP_READ;
                   else if(socketChannel.isConnectionPending())interest = SelectionKey.OP_CONNECT;
                   socketChannel.register(selector, interest);
                   while(true)
                        int nn = selector.select();
                        System.out.println("nn="+nn);
                        Set keys = selector.selectedKeys();
                        for(Iterator i = keys.iterator(); i.hasNext();)
                             SelectionKey key = (SelectionKey) i.next();
                             i.remove();
                             if (key.isConnectable())
                                  SocketChannel keyChannel = (SocketChannel) key.channel();
                                  System.out.println("Connected "+keyChannel.finishConnect());
                                  key.interestOps(SelectionKey.OP_READ);
                             if (key.isReadable())
                                  SocketChannel keyChannel = (SocketChannel) key.channel();
                                  String m = Help.read(keyChannel);
                                  display(m);
              } catch (IOException e) {
                   e.printStackTrace();
         private void display(final String m) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        area.append(m+"\n");
                        textFieed.setText("");
         private void sendMessage(final String m) {
              Thread t = new Thread(new Runnable() {
                   public void run() {
                        try {
                             Help.write(m, socketChannel);
                        } catch (IOException e) {
                             e.printStackTrace();
              t.start();
         public Client() {
              addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(1);
              textFieed.addKeyListener(new KeyAdapter() {
                   public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode()== KeyEvent.VK_ENTER) {
                             String m = textFieed.getText();
                             sendMessage(m);
              area.setEditable(false);
              getContentPane().add(textFieed, "North");
              getContentPane().add(new JScrollPane(area));
              setBounds(200, 200, 400, 300);
              show();
         private String messageToSend;
         private JTextArea area = new JTextArea();
         JTextField textFieed = new JTextField();
         public static void main(String[] args) {
              Client s = new Client();
              s.work();

  • NIO Socket implementation - delay between select and get data from socket

    Hi all,
    I have implemented a internal CallAPI for RPC over a socket connection. It works fine but if there are more than five clients and some load I have the phenomena that the READ selector returns a SelectorKey but I did not get any data from the socket.
    My implementation is based on NIO has following components:
    + Accept-Thread
    Thread handles new clients.
    + Read-Thread
    Thread handles the data from the socket for the registered client. Each request is handled in an own Process-Thread. A Thread-Pool implementation is used for processing.
    + Process-Thread
    The Process-Thread reads the data from the socket and starts the processing of the logical request.
    In my tests I get the notification of data at the socket. The Process-Thread want to read the data for the socket, but no data are available. In some situations if have to read about 20 times and more to get the data. Between each read attempt I have inserted a sleep in the Process-Thread if no data was available. This have improved the problem, but it already exists. I tested the problem with several systems and jvm's but it seams that it is independent from the system.
    What can I to do improve the situation?
    I already include the read implementation from the grizzly-Framework. But it doesn't improve the situation.
    Socket - Init
         protected void openSocket( String host, int port ) throws IOException
              serverChannel = ServerSocketChannel.open();
              serverChannel.configureBlocking( false );
              serverSocket = serverChannel.socket();
              serverSocket.setReuseAddress( true );
              this.serverhost = host;
              this.serverport = port;
              this.srvAcceptSelector = Selector.open();
              this.srvReadSelector = Selector.open();
              InetSocketAddress isa = null;
              if ( serverhost != null )
                   isa = new InetSocketAddress( this.serverhost, this.serverport );
              else
                   isa = new InetSocketAddress( this.serverport );
              serverSocket.bind( isa, 50 );
              serverChannel.register( this.srvAcceptSelector, SelectionKey.OP_ACCEPT );
         }New Client � Init
         // New Client
         if ( key.isAcceptable())
              keyCountConnect++;
              ServerSocketChannel actChannel =
                   (ServerSocketChannel) key.channel();
              // Socket akteptieren
              SocketChannel actSocket = actChannel.accept();
              if ( actSocket != null )
                   actSocket.finishConnect();
                   actSocket.configureBlocking( false );
                   actSocket.socket().setTcpNoDelay( true );
                   this.registerSocketList.add( actSocket );
                   this.srvReadSelector.wakeup();
         }Read Data from Socket
        protected int readDatafromSocket( ByteArrayOutputStream socketdata )
             throws IOException
             int readedChars = 0;
            int count = -1;
            Selector readSelector = null;
            SelectionKey tmpKey = null;
            if ( sc.isOpen())
                  ByteBuffer inputbuffer = null;
                 try
                      inputbuffer = bufferpool.getBuffer();
                      while (( count = sc.read( inputbuffer )) > 0 )
                           readedChars += count;
                          inputbuffer.flip();
                           byte[] tmparray=new byte[inputbuffer.remaining()];
                           inputbuffer.get( tmparray );
                           socketdata.write( tmparray );
                          inputbuffer.clear();
                      if ( count < 0 )
                           this.closeSocket();
                           if( readedChars == 0 )
                                readedChars = -1;
                           if ( log.isDebug())
                                  log.debug( "Socket is closed! " );
                      else if ( readedChars == 0 )
                           if ( log.isDebug())
                                  log.debug( "Reread with TmpSelector" );
                           // Glassfish/Grizzly-Implementation
                         readSelector = SelectorFactory.getSelector();
                         if ( readSelector == null )
                              return 0;
                          count = 1;
                          tmpKey = this.sc.register( readSelector, SelectionKey.OP_READ );
                         tmpKey.interestOps(
                              tmpKey.interestOps() | SelectionKey.OP_READ );
                         int code = readSelector.select( 500 );
                         tmpKey.interestOps(
                             tmpKey.interestOps() & ( ~SelectionKey.OP_READ ));
                         if ( code == 0 )
                             return 0;
                             // Return on the main Selector and try again.
                           while (( count = sc.read( inputbuffer )) > 0 )
                                readedChars += count;
                               inputbuffer.flip();
                                byte[] tmparray=new byte[inputbuffer.remaining()];
                                inputbuffer.get( tmparray );
                                socketdata.write( tmparray );
                               inputbuffer.clear();
                           if ( count < 0 )
                                this.closeSocket();
                                if( readedChars == 0 )
                                     readedChars =-1;
                           else if ( count == 0 )
                                  // No data
                 finally
                      if ( inputbuffer != null )
                           bufferpool.releaseBuffer( inputbuffer );
                           inputbuffer = null;
                      // Glassfish-Implementierung
                    if ( tmpKey != null )
                        tmpKey.cancel();
                    if ( readSelector != null)
                        // Bug 6403933
                         try
                            readSelector.selectNow();
                         catch (IOException ex)
                        SelectorFactory.returnSelector( readSelector );
            return readedChars;
        }Thanks for your time.

    I've commented on that blog before. It is rubbish:
    - what does 'overloading the main Selector' actually mean? if anything?
    - 'Although this not clearly stated inside the NIO API documentation': The API documentation doesn't say anything about which Selector you should register channels with. Why would it? Register it with any Selector you like ...
    - 'the cost of maintaining multiple Selectors can reduce scalability instead of improving it' Exactly. So what is the point again?
    - 'wrapping a ByteBuffer inside a ByteBufferInputStream:' Code is rubbish and redundant. java.nio.channels.Channels has methods for this.
    There is no a priori advantage to using multiple Selectors and threads unless you have multiple CPUs. And even then not much, as non-blocking reads and writes don't consume significant amounts of CPU. It's the processing of the data once you've got it that takes the CPU, and that should be done in a separate thread.
    So I would re-evaluate your strategy. I suspect you're getting the channel registered with more than one Selector at a time. Implement it the simple way first then see if you really have a problem with 'overloading the main Selector' ...

  • Why do I get IOException on nio read from channel before all data is read?

    I am working on an NIO based http client library but I've noticed two problems.
    #1: I have been testing against an http server that has authentication turned on. Hence, any request that comes its way will respond with a '401 Authentication Required' response. In the case of a POST, I've noticed that this particular http server does not wait for the body to arrive before responding. As soon as it gets the headers, it dumps the 401 response onto the channel and closes the connection. My library then gets an IOException on the next write to the channel even though I've received write interest event. (I'm using non blocking mode)
    Whether I get the exception depends on timing. Sometimes, my writes work and the exception is averted. Sometimes not. The longer I delay since the time I get the write interest event, the more likely it is the exception will occur.
    Now, in this situation, I really think it's the http server that is violating the http protocol. I give a valid content length that is not zero but it does not wait for me to finish my request. The moment I write the last empty line of the header section, it responds and closes the channel. Even though I don't think this is correct, my library has to deal with it. So in this situation, I've decided my library will abandon the write phase and move on to reading the response.
    NOTE: In the majority of cases, a client would have already authenticated by landing on some page that could produce a POST in the first place. However, for technical reasons I can't mention here, I must support the case that the very first (unathenticated) request to the server is a POST.
    2) After #1 above occurs, reading from the channel will also throw an IOException but only on Windows. Sometimes I get the headers only, sometimes the whole document, sometimes nothing. Again, the longer I delay reading (since the time I get the read interest event) the more likely it is the exception will be thrown. This NEVER happens on Linux. I always get the full response on Linux after the #1 happens even if I put long delays between reads.
    I can understand #1 happening but #2 should not. I can always see the complete response data on the wire using a network protocol analyser. The data is there every time but my library doesn't always get it.
    In situation 2, there is nothing I can do. If I don't receive the data, I have to respond with an error even though the request was successful.
    I have stripped down my library to the bare essentials and can reproduce the problem in a self-contained environment every time.
    Any ideas why the discrepency between Windows/Linux? Does this seem right?

    I read through the section you mentioned. I realize the connection may be dropped at any time. Handling this is no problem. It is reported as an exception to the client. However, this situation is different. I still see no provision that allows a server to respond to a half written request. A request is defined to include an optional message body (Section 5). The client dictates whether it is optional, not the server. Furthermore, section 6 clearly states "After receiving and interpreting a request message, a server responds with an HTTP response message.". To me, this implies the server must wait for the entire request before responding even if its a waste of time. This particular server is attempting to short circuit what I see is the required request/response cycle. In doing so, it is causing me some pain in trying to deliver its response since it seems on windows this interferes with my ability to read it.
    The simple answer to this is to process reads before writes, i.e. OP_READ before OP_WRITE. I tried this as well. Originally, I was not even registering READ interest while I was writing my request. (I saw no reason to. I don't want to give my client a response while they are writing their request.) But even when I do register READ interest while I'm writing (and process read events before write), the read event still produces no data and no eof (-1) indication on the read. The discrepency between linux and windows is bothering me. No matter what I do, I can't deliver the response even though its written to the channel by my peer. I think I will supply some code and see if anyone can get it to work on windows.Edited by: r2rossi on Sep 24, 2008 10:42 AMEdited by: r2rossi on Sep 24, 2008 10:43 AM
    Edited by: r2rossi on Sep 24, 2008 10:45 AM
    Edited by: r2rossi on Sep 24, 2008 10:46 AM

  • Problematic frame: # J java.nio.MappedByteBuffer.load()

    Helo all...
    I'm getting an error when generating a PDF using BIRT Framework in Eclipse. Nothing fancy, just compiling a simple report to pdf.
    The problem is, the JVM crashes with the following error:
    # A fatal error has been detected by the Java Runtime Environment:
    # EXCEPTION_IN_PAGE_ERROR (0xc0000006) at pc=0x0190f0be, pid=5848, tid=2392
    # JRE version: 7.0_09-b05
    # Java VM: Java HotSpot(TM) Client VM (23.5-b02 mixed mode, sharing windows-x86 )
    **# Problematic frame:
    # J java.nio.MappedByteBuffer.load()Ljava/nio/MappedByteBuffer;**
    # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
    # An error report file with more information is saved as:
    # C:\Users\luis\Desktop\teste\birt\hs_err_pid5848.log
    # If you would like to submit a bug report, please visit:
    # http://bugreport.sun.com/bugreport/crash.jsp
    I already tried:
    1. Run the program in another computers - it worked
    2. Reinstall Java on the computer - It did nothing
    3. I check the integrity of the disk C: - Nothing
    I already spent two days trying to fix this and I don't have any progress. I can't find a solution on the web either.
    Thanks in advance

    Thanks for the help.
    But it can not be related to BIRT because it works in every other computer that I tried so far. There is only one computer that not works properly.
    If it were BIRT's fault, it wouldn't work in any computer.
    Thanks again

  • 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.

  • SSLSocket to support NIO - feature request voting

    Hello All,
    I know there were many discussions here regarding this subject.
    I've seen the SSLEngine solution for the problem... But I didn't like it since it is too complicated.
    For my understanding SSLSocket inherits Socket so an application that can handle Sockets should be able to handle SSLSocket without writing a specific code besides the factory.
    NIO allows Socket to be none blocking... So why SSLSocket which is a Socket does not?
    If I write a Web server in Java, why should I deal with none SSL and SSL connections in a different way?
    I recently wrote one threaded NIO server and was amazed that I could not use SSL with the same implementation.
    I've opened a feature request for Java, but they told me to gain support for this subject here before they will consider it...
    As I understand I can re-implement SSLSocket to use SSLEngine and support NIO with blocking and none blocking support... But I think Sun should do it.
    One caveat is to make sure that the SSLSocket HandshakeCompletedListener should be called by a daemon thread, so that it will not block other sockets while certificate verification occur.
    Of course when I refer to SSLSocket I also refer to SSLServerSocket.
    Can you please comment regarding this issue... Every comment will be welcomed!
    Best Regards,
    Alon Bar-Lev

    nah, I am very glad they released an engine separate from transport allowing encryption on any transport.
    I am also working on an abstraction of nio that you may be interested in if you don't want to do the security yourself......it is here...
    http://sourceforge.net/projects/channelmanager
    Right now, it only contains the api, but there are 3 implementations behind it right now with 3 to be added.
    1. Basic implementation that does just nio
    2. Secure implementation that implements same api and uses implementation 1
    3. Packettizer implementation which puts things in payloads with headers and footers
    4. (to be added) Threadpool implementation allowing a threadpool to be inserted in the stack somewhere
    5. (to be added) TestProxy implementation allowing exxceptions to be thrown on purpopse to test a system on a bad network....can test failure on bind, connect, read, write, etc....everything.
    6. denial of service layer.
    7. Exception catch layer to protect #1 and #4 mainly from bad clients that throw exceptions back to the channelmanager.
    Each one of these layers (2 - 4) implements the same api and uses the same api so 2 -4 are all proxies. You can reorganize the proxies as you want.
    The secure one is almost done. Any comments on the api will be welcome.
    thanks,
    dean

  • How to find out how many memory is used for NIO

    is there any way to find out how many memory is used for nio in a virtual machine. ?
    I know that is possible to find out how many total, free and used memory the heap has by using java.lang.Runtime#totalMemory...
    We sometimes expect errors that it is not possible to create any more connections because of the NIO memory size but the heap is still ok. Today we had an error where 170mbytes of heap where left but it was not possible to create new tcp connections because of an exception:
    javax.naming.NamingException: java.net.SocketException: No buffer space available (maximum connections reached?): connect
    The number of TCP-Connections was ok (<500).
    It would be very nice if someone knows how to find out how the amount of memory that NIO buffers use can be determined within Java 1.4.
    best regards
    benjamin

    We have to use 1.4.2_03. This is because of the special environment we are running on.
    We did also figured out that there are some NIO Memory Bugs but we since we are not allowed to upgrade the used Virtual Machine we have to live with these errors.
    The problem that we currently have is within a Server and because of this circumstance we are trying to find a workaround or way to find out how many memory is allocated. If we would know how to get this value we could restart the servers as a workaround after the value reaches a threshold.
    We are also very sad that we can`t easily upgrade/update to the latest 1.4.2 Version or the newest 1.5 to get rid of these NIO Bugs!

  • Is this a bug of NIO???

    I am using nio to write a network server.
    I use following code to close a SocketChannel:
    Socket s = sc.socket();
              if (s != null) {
                   try {
                        s.close();
                   } catch (IOException e) {     
                        e.printStackTrace();
              sc.close();
    It works fine. But sometimes s.close() will throw a java.lang.Error, this will lead my server to crash!
    StackTrace:
    java.lang.Error: Untranslated exception
         at sun.nio.ch.Net.translateToSocketException(Net.java:65)
         at sun.nio.ch.SocketAdaptor.close(SocketAdaptor.java:354)
    Caused by: java.io.IOException: Unable to finish a non-blocking socket action (This error message is translated by me, I am not in USA)&#12290;
         at sun.nio.ch.SocketDispatcher.close0(Native Method)
         at sun.nio.ch.SocketDispatcher.preClose(SocketDispatcher.java:44)
         at sun.nio.ch.SocketChannelImpl.implCloseSelectableChannel(SocketChannelImpl.java:684)
         at java.nio.channels.spi.AbstractSelectableChannel.implCloseChannel(AbstractSelectableChannel.java:201)
         at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:97)
         at sun.nio.ch.SocketAdaptor.close(SocketAdaptor.java:352)
         ... 18 more
    The error will be throwed if I called it N times, N < 2000.
    Runing env:
    WindowsXp, Amd dual core, 1G ram, JDK1.6.02
    The Logic of my test case:
    Server S listen to port 8080 with one select thread,
    Client A, Client B
    A connect to S, and send a package to get some resource, and A wait
    B connect to S, and send a package to get the same resource, This cause S cause Client A,
    A finds it disconnected, it reconnect and do the same as B
    B finds it disconnected, it reconnect too ....
    now, there is a loop.
    (all these are doing in the select thread)
    I think A and B will do these forever, but after some time( serveral seconds ), the Error will be thrown and
    server crashed.
    I google it, and I found nothing useful. Is this a bug??

    B connect to S, and send a package to get the same resource, This cause S cause Client A, A finds it disconnected, it reconnect and do the same as BI don't understand this. Why does anything done by B have anything to do with A? let alone making it reconnect? There is something seriously wrong with the application logic here if that's the result.
    NIO isn't that matureWell, it wasn't that mature in 1.4.0 or 1.4.1, but that's five years ago. Haven't found anything major in it for years.
    @OP: does it work better if you close the channel directly rather than its socket?

  • [java.nio] StreamCorruptedException when deserializing objects

    Hello everybody!
    I made a messaging (chat) program using java.io where all the client-server communication is done by serializing small objects. Now I would like to covert the server side to the NIO concept and I'm already struck. I successfully pass objects to the client and the client deserializes them, but only the first one! When it try to read the second it fails with a StreamCorruptedException.
    Here�s a sample (testing) code. In the server run() method I first serialize a string, then get its byte array from ByteArrayOutputStream and in the loop periodically send this byte array through the channel. On the client side I just read the deserialized object.
    Server run():
    public void run() {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject("abcdefgh");
                byte[] objectArr = baos.toByteArray();
                baos.close();
                oos.close();
                ByteBuffer buff = ByteBuffer.allocate(objectArr.length);
                buff.put(objectArr);
                buff.flip();
                while(true) {
                    selector.select();
                    Set keys = selector.selectedKeys();
                    for (Object o : keys) {
                        SelectionKey key = (SelectionKey)o;
                        if (key.isAcceptable()) {
                            ServerSocketChannel server = (ServerSocketChannel) key.channel();
                            clientChannel = server.accept();
                            if (clientChannel == null)
                                continue;
                            clientChannel.configureBlocking(false);
                            SelectionKey clientKey = clientChannel.register(selector, SelectionKey.OP_WRITE);
                        } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                    try {
                        Thread.currentThread().sleep(2000);
                    } catch (InterruptedException e) {
                        return;
            } catch (IOException e) {
                e.printStackTrace();
        }Client run():
    public void run() {
            try {
                soc = new Socket("localhost", 4000);
                ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
                while(true) {
                    Object d = ois.readObject();
                    System.out.println("data = " + d.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
        }At the second read I get a StreamCorruptedException.
    Apart from this I would like some hints in how to implement the application with NIO. For example how can I tell the objects apart on the client side � should I send every time a byte array before the object, which tells the length of the next coming object? This is probably not a 100% bulletproof solution and presents additional data transfer?
    Than you in advance!

    OK, I found a solution but I don't like it, because I don't understand it.
    The ObjectOutputStream adds a header (4 bytes) to the stream - if I send the array with those four bytes I get an StreamCorruptedException. If I send the array without the header I also get a StreamCorruptedException: "invalid stream header".
    If I reconstruct the object, by calling ObjectOutputStream.writeObject() and get it's byte array from ByteArrayOutputStream.toByteArray(), every time I have to fill the ByteBuffer, then it works.
    Here's the modified sending block, for the above example:
    } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                //* ---- added code ---------
                                baos.reset();
                                oos.writeObject("abcdefgh");
                                objectArr = baos.toByteArray();
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                        }   I really don't understand why I have to write the object in the object stream every time. I used ObjectOS and ByteArrayOS, to get the object byte array and then I thought I could forget about those streams and use this array to fill the ByteBuffer. What changes if I send the object through this process with every iteration (and how this harms speed - it's like sending everything twice)? If someone would explain this to me I would appreciate it much.

  • Use of the bug level variable  -Dsun.nio.ch.bugLevel=1.4

    Hi,
    I wanted to understand how java uses the variable sun.nio.ch.bugLevel .. and what is the value that it needs to be set. searching for this variable gave me a result where some one has set -Dsun.nio.ch.bugLevel=1.4 as the jvm option.
    ISSUE: I am randomly encountering a NullPointerException while calling Selector.open
    CAUSE:
    Here is the stack trace:
    "java.lang.NullPointerException
    at sun.nio.ch.Util.atBugLevel(Util.java:326)
    at sun.nio.ch.SelectorImpl.<init>(SelectorImpl.java:40)
    at sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:104)
    at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:26)
    at java.nio.channels.Selector.open(Selector.java:209)
    This is cause due to a bug in java 1.5 (which has been fixed in Java 7)
    http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=9ea0db6110bd136e5288fa753945f?bug_id=6427854
    This bug has not yet been fixed in Java 1.5
    Here is the excerpt from the java 7 code:
    https://openjdk.dev.java.net/source/browse/openjdk/jdk/trunk/jdk/src/share/classes/sun/nio/ch/Util.java?rev=257&view=markup
    // -- Bug compatibility --
    private static volatile String bugLevel = null;
    static boolean atBugLevel(String bl) { // package-private
    if (bugLevel == null) {
    if (!sun.misc.VM.isBooted())
    return false;
    String value = AccessController.doPrivileged(
    new GetPropertyAction("sun.nio.ch.bugLevel"));
    bugLevel = (value != null) ? value : "";
    return bugLevel.equals(bl);
    java -version "1.5.0_15"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04)
    Java HotSpot(TM) Client VM (build 1.5.0_15-b04, mixed mode, sharing)
    Thanks in advance
    Vijay

    Hi Tim,
    This is a know issue, the bug has already been logged. Parameters(param1, param2 etc) works only on Non Repeating Heading Section, but not in Repeating Section and Non Repeating Footer Section.
    Thanks,
    Seshan K.

  • Java NIO locking and NTFS network resources

    Hi all - just ran into a really nasty situation and I was wondering if anyone else has hit it and might have some suggestions.
    Platform: JRE 1.4_02 on a Win XP machine
    The following test code locks a file, then copies it to another location using NIO.
    When I run it with source path on my local drives (C), it works fine. If I run it with source path on a network shared resource, it fails with an IOException with description 'Error performing inpage operation'.
    If I disable the lock immediately before the copy operation, it works fine.
    My conclusion is that there is something about the NIO locking implementation that prevents it from working properly with NTFS volumes on other hosts. Can this be right? I've found the following bug report:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774175
    but this seems like a huge problem that would prevent folks from using NIO in many, many applications. Maybe I'm wrong on something here...
    Anyway, here's the test code:
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    import java.nio.channels.FileLock;
    * Created on May 28, 2004
    * (c) 2004 Trumpet, Inc.
    * @author kevin
    public class test {
         private void createFile(File f) throws IOException{
              FileOutputStream os = new FileOutputStream(f);
              for(int i = 0; i < 10; i++){
                   os.write(i);
              os.close();
         public test() {
              boolean testWithReleasingLockPriorToCopy = false;
              final File f1= new File("w:/temp/test2.lok");
              final File f2 = new File("w:/temp/test.lok");
              f1.delete();
              f2.delete();
              try {
                   createFile(f1);
                   RandomAccessFile raf1 = new RandomAccessFile(f1, "rw");
                   RandomAccessFile raf2 = new RandomAccessFile(f1, "rw");
                   FileChannel ch1 = raf1.getChannel();
                   FileChannel ch2 = raf2.getChannel();
                   FileLock flock1 = ch1.lock();
                  if (!f2.getParentFile().exists() && !f2.getParentFile().mkdirs())
                       throw new IOException("Unable to create directories for destination file '" + f2 + "'");
                  if (testWithReleasingLockPriorToCopy)
                       flock1.release();
                   ch1.transferTo(0, raf1.length(), ch2);
                   raf1.close();
                   raf2.close();
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args) {
              test t = new test();
    }Does anyone have any pointers here? I need to be able to exclusively lock a file on a network drive (preventing any other applications from opening it), then make a copy of it. I can't use regular stream operations, because the lock prevents them from working properly (it appears that, once you grab a file lock using NIO, the only way your application can use the file is via the NIO operations - using stream operations fails...).
    Thanks in advance for any help!
    - Kevin

    i've run into the same problem recently, channels working fine for local file locking, but when you turn to the network, they fail to accurately handle locks.
    i ended up writing a jni utility to ship with my java application that locks files using native windows calls.
    my .c file ends up looking something like this:
    JNIEXPORT jint JNICALL Java_Mapper_NativeUtils_LockFile
    (JNIEnv *env, jobject obj, jstring filename)
    const char* ntvFilename = (*env)->GetStringUTFChars(env, filename, 0);
    int retVal = (int)CreateFile
    ntvFilename
    , GENERIC_WRITE
    , FILE_SHARE_READ
    , 0
    , OPEN_EXISTING
    , FILE_FLAG_SEQUENTIAL_SCAN
    , 0
    //add code to throw java exceptions based on retVal
    if (retVal == (int)INVALID_HANDLE_VALUE)
    return retVal;
    (*env)->ReleaseStringUTFChars(env, filename, ntvFilename);
    return retVal;
    JNIEXPORT jboolean JNICALL Java_Mapper_NativeUtils_UnlockFile
    (JNIEnv *env, jobject obj, jint handle)
         CloseHandle((void *)handle);
    return 1;
    it's a little shy on the error checking side, but it provides support for network file locking that java seems to lack.

  • Nio ByteBuffer and memory-mapped file size limitation

    I have a question/issue regarding ByteBuffer and memory-mapped file size limitations. I recently started using NIO FileChannels and ByteBuffers to store and process buffers of binary data. Until now, the maximum individual ByteBuffer/memory-mapped file size I have needed to process was around 80MB.
    However, I need to now begin processing larger buffers of binary data from a new source. Initial testing with buffer sizes above 100MB result in IOExceptions (java.lang.OutOfMemoryError: Map failed).
    I am using 32bit Windows XP; 2GB of memory (typically 1.3 to 1.5GB free); Java version 1.6.0_03; with -Xmx set to 1280m. Decreasing the Java heap max size down 768m does result in the ability to memory map larger buffers to files, but never bigger than roughly 500MB. However, the application that uses this code contains other components that require the -xMx option to be set to 1280.
    The following simple code segment executed by itself will produce the IOException for me when executed using -Xmx1280m. If I use -Xmx768m, I can increase the buffer size up to around 300MB, but never to a size that I would think I could map.
    try
    String mapFile = "C:/temp/" + UUID.randomUUID().toString() + ".tmp";
    FileChannel rwChan = new RandomAccessFile( mapFile, "rw").getChannel();
    ByteBuffer byteBuffer = rwChan.map( FileChannel.MapMode.READ_WRITE,
    0, 100000000 );
    rwChan.close();
    catch( Exception e )
    e.printStackTrace();
    I am hoping that someone can shed some light on the factors that affect the amount of data that may be memory mapped to/in a file at one time. I have investigated this for some time now and based on my understanding of how memory mapped files are supposed to work, I would think that I could map ByteBuffers to files larger than 500MB. I believe that address space plays a role, but I admittedly am no OS address space expert.
    Thanks in advance for any input.
    Regards- KJ

    See the workaround in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4724038

  • Converting from CP1252 (Windows) to ISO 8859-1 doesn't work with java.nio?

    Hi
    I'm trying to write some code that checks whether an InputStream contains only characters with a given encoding. I'm using java.nio for that. For tests, I downloaded some character set examples from http://www.columbia.edu/kermit/csettables.html
    When creating the CharsetDecoder, I want to get all errors:
        Charset charset = Charset.forName( encoding );
        CharsetDecoder decoder = charset.newDecoder();
        decoder.onMalformedInput( CodingErrorAction.REPORT );
        decoder.onUnmappableCharacter( CodingErrorAction.REPORT );I then read an InputStream and try to convert it. If that fails, it can't contain the desired encoding:
        boolean isWellEncoded = true;
        ByteBuffer inBuffer = ByteBuffer.allocate( 1024 );
        ReadableByteChannel channel = Channels.newChannel( inputStream );
        while ( channel.read( inBuffer ) != -1 )
          CharBuffer decoded = null;
          try
            inBuffer.flip();
            decoded = decoder.decode( inBuffer );
          catch ( MalformedInputException ex )
            isWellEncoded = false;
          catch ( UnmappableCharacterException ex )
            isWellEncoded = false;
          catch ( CharacterCodingException ex )
            isWellEncoded = false;
          if ( decoded != null )
            LOG.debug( decoded.toString() );
          if ( !isWellEncoded )
            break;
          inBuffer.compact();
        channel.close();
        return isWellEncoded;Now I want to check whether a file containing Windows 1252 characters is ISO-8859-1. From my point of view, the code above should fail when it gets to the Euro symbol (decimal 128), since that's not defined in ISO-8859-1.
    But all I get is a ? character instead:
    (})  125  07/13  175  7D                 RIGHT CURLY BRACKET, RIGHT BRACE
    (~)  126  07/14  176  7E                 TILDE
    [?]  128  08/00  200  80  EURO SYMBOL
    [?]  130  08/02  202  82  LOW 9 SINGLE QUOTEI also tried to replace the faulty character, using
        decoder.onUnmappableCharacter( CodingErrorAction.REPLACE );
        decoder.replaceWith("!");but I still get the question marks.
    I'm probably doing something fundamentally wrong, but I dont get it :-)
    Any help is greatly appreciated!
    Eric

    As a suggestion....create a complete example demonstrating the problem. It shouldn't have channel in it since that wouldn't appear to be the problem (decoding is.) You should create the byte array in the example code - populate it with the byte sequence that you think should work. And your code should then demonstrate that it doesn't. Then post that.

  • JVM crash on NIO

    Hi,
    I have written a piece of software that does a lot of NIO work by accepting connections on a few Server sockets and reading/writing data on the resulting client sockets. However, "suddenly" my JVM starting crashing shortly after a few tens/hundred clients have connected to this server. I'm saying "suddenly" because I cannot say that the code did not change from the previous version, it did - but whatever I did, crashing the JVM is something I shouldn't be able to do.
    The dump report is below, I'd appreciate any help guys ! :)
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # EXCEPTION_GUARD_PAGE (0x80000001) at pc=0x25fd1a49, pid=6656, tid=5644
    # Java VM: Java HotSpot(TM) Server VM (1.5.0_05-b05 mixed mode)
    # Problematic frame:
    # C [CtxLsp.dll+0x1a49]
    --------------- T H R E A D ---------------
    Current thread (0x26180130): JavaThread "CommunicationManager" [_thread_in_native, id=5644]
    siginfo: ExceptionCode=0x80000001, ExceptionInformation=0x00000001 0x283e0820
    Registers:
    EAX=0x00001d1c, EBX=0x283dc740, ECX=0x00001cdc, EDX=0x283d95b0
    ESP=0x283d9360, EBP=0x00000000, ESI=0x26026ec8, EDI=0x283d94ac
    EIP=0x25fd1a49, EFLAGS=0x00010202
    Top of Stack: (sp=0x283d9360)
    0x283d9360: 283d9394 283dd744 25fd1cee 283d94ac
    0x283d9370: 283de748 25fd961b 283d93a8 283d94ac
    0x283d9380: 283d95b0 283de748 000b2e30 283d970c
    0x283d9390: 283dc740 26026e08 26026ec8 2602ff68
    0x283d93a0: 25feb018 00000001 00000046 00002374
    0x283d93b0: 0000237c 00002228 00002218 000021d0
    0x283d93c0: 000021c0 0000218c 00002118 000020f4
    0x283d93d0: 000020cc 000020bc 000020a8 00002098
    Instructions: (pc=0x25fd1a49)
    0x25fd1a39: 8d a4 24 00 00 00 00 8b 0e e8 49 51 00 00 8b 0f
    0x25fd1a49: 89 44 8f 04 ff 07 8b 76 08 85 f6 75 ea 5e 33 c0
    Stack: [0x283a0000,0x283e0000), sp=0x283d9360, free space=228k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [CtxLsp.dll+0x1a49]
    [error occurred during error reporting, step 120, id 0xc0000005]
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(JI[I[I[IJ)I+0
    j sun.nio.ch.WindowsSelectorImpl$SubSelector.poll()I+43
    j sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(Lsun/nio/ch/WindowsSelectorImpl$SubSelector;)I+1
    j sun.nio.ch.WindowsSelectorImpl.doSelect(J)I+63
    j sun.nio.ch.SelectorImpl.lockAndDoSelect(J)I+37
    v ~C2IAdapter
    J com.aternity.epm.core.CommunicationManager.doOnce()V
    v ~I2CAdapter
    j com.aternity.system.common.InterruptibleTask.run()V+8
    j java.lang.Thread.run()V+11
    v ~StubRoutines::call_stub
    --------------- P R O C E S S ---------------
    Java Threads: ( => current thread )
    0x266e4e08 JavaThread "pool-1-thread-5" [_thread_blocked, id=6960]
    0x261d4d50 JavaThread "pool-1-thread-4" [_thread_blocked, id=3516]
    0x261ece50 JavaThread "pool-1-thread-3" [_thread_blocked, id=4404]
    0x26244318 JavaThread "pool-1-thread-2" [_thread_blocked, id=6444]
    0x0003d8b8 JavaThread "DestroyJavaVM" [_thread_blocked, id=6652]
    0x26232000 JavaThread "EventConsumerAggregator" [_thread_blocked, id=256]
    0x26256d08 JavaThread "EventConsumerAggregator" [_thread_blocked, id=3644]
    0x26256b88 JavaThread "EventConsumerAggregator" [_thread_blocked, id=6980]
    0x26232f90 JavaThread "RawDataReporterEventConsumer" [_thread_blocked, id=7176]
    0x2622fd90 JavaThread "ResourceManagerInterface" [_thread_blocked, id=7104]
    =>0x26180130 JavaThread "CommunicationManager" [_thread_in_native, id=5644]
    0x261ea2b0 JavaThread "Statistics" [_thread_blocked, id=7888]
    0x25e16238 JavaThread "OutgoingMessageDispatcher" [_thread_blocked, id=2100]
    0x25e09948 JavaThread "IncomingMessageDispatcher" [_thread_blocked, id=7896]
    0x25e11048 JavaThread "MessageListenerThread - epm1" [_thread_blocked, id=5272]
    0x25de8c40 JavaThread "MessageListenerThread - epmsvc" [_thread_blocked, id=2016]
    0x263c4d88 JavaThread "MessageListenerThread - epmservices1" [_thread_blocked, id=5640]
    0x26241e78 JavaThread "pool-2-thread-1" [_thread_blocked, id=7868]
    0x2622db20 JavaThread "pool-1-thread-1" [_thread_blocked, id=5676]
    0x261aad98 JavaThread "MessageListenerThread - client1" [_thread_blocked, id=5848]
    0x268d2618 JavaThread "MessageListenerThread - GR master" [_thread_blocked, id=7848]
    0x26370c78 JavaThread "Timer-0" daemon [_thread_blocked, id=5520]
    0x26326008 JavaThread "Thread-3" [_thread_blocked, id=5868]
    0x2630dc98 JavaThread "Thread-2" [_thread_blocked, id=1792]
    0x26188a88 JavaThread "UIL2(SocketManager.MsgPool@193c0cf client=192.168.111.113:8093)#1" daemon [_thread_blocked, id=6948]
    0x26fbb4c8 JavaThread "Connection Monitor Thread" daemon [_thread_blocked, id=3112]
    0x26343d58 JavaThread "UIL2.SocketManager.WriteTask#2 client=192.168.111.113:8093" daemon [_thread_blocked, id=6860]
    0x268bc008 JavaThread "UIL2.SocketManager.ReadTask#1 client=192.168.111.113:8093" daemon [_thread_in_native, id=6892]
    0x26fabe68 JavaThread "RMI ConnectionExpiration-[192.168.111.113:1098]" daemon [_thread_blocked, id=6184]
    0x26227e48 JavaThread "GC Daemon" daemon [_thread_blocked, id=4552]
    0x25e049a8 JavaThread "RMI RenewClean-[192.168.111.113:1098]" daemon [_thread_blocked, id=5044]
    0x25e20610 JavaThread "Thread-0" daemon [_thread_blocked, id=6168]
    0x25a31120 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=2524]
    0x00ac7970 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4792]
    0x00ac6678 JavaThread "CompilerThread1" daemon [_thread_blocked, id=5284]
    0x00ac5818 JavaThread "CompilerThread0" daemon [_thread_blocked, id=5828]
    0x00ac48e8 JavaThread "AdapterThread" daemon [_thread_blocked, id=1212]
    0x00ac3d60 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=7520]
    0x00abb028 JavaThread "Finalizer" daemon [_thread_blocked, id=1068]
    0x00aba398 JavaThread "Reference Handler" daemon [_thread_blocked, id=8160]
    Other Threads:
    0x00038cb8 VMThread [id=6460]
    0x00ac38d8 WatcherThread [id=5072]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
    [0x0003d078/0x00002ee0] Heap_lock - owner thread: 0x25e09948
    Heap
    def new generation total 576K, used 16K [0x02ad0000, 0x02b70000, 0x06140000)
    eden space 512K, 3% used [0x02ad0000, 0x02ad4010, 0x02b50000)
    from space 64K, 0% used [0x02b60000, 0x02b60000, 0x02b70000)
    to space 64K, 0% used [0x02b50000, 0x02b50000, 0x02b60000)
    tenured generation total 2812K, used 1685K [0x06140000, 0x063ff000, 0x214d0000)
    the space 2812K, 59% used [0x06140000, 0x062e57f0, 0x062e5800, 0x063ff000)
    compacting perm gen total 16384K, used 9128K [0x214d0000, 0x224d0000, 0x254d0000)
    the space 16384K, 55% used [0x214d0000, 0x21dba1d8, 0x21dba200, 0x224d0000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040c000      C:\dev\Java\jdk1.5.0_05\bin\java.exe
    0x7c900000 - 0x7c9b0000      C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c8f4000      C:\WINDOWS\system32\kernel32.dll
    0x77dd0000 - 0x77e6b000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77e70000 - 0x77f01000      C:\WINDOWS\system32\RPCRT4.dll
    0x77c10000 - 0x77c68000      C:\WINDOWS\system32\MSVCRT.dll
    0x6d840000 - 0x6dbd8000      C:\dev\Java\jdk1.5.0_05\jre\bin\server\jvm.dll
    0x77d40000 - 0x77dd0000      C:\WINDOWS\system32\USER32.dll
    0x77f10000 - 0x77f57000      C:\WINDOWS\system32\GDI32.dll
    0x76b40000 - 0x76b6d000      C:\WINDOWS\system32\WINMM.dll
    0x629c0000 - 0x629c9000      C:\WINDOWS\system32\LPK.DLL
    0x74d90000 - 0x74dfb000      C:\WINDOWS\system32\USP10.dll
    0x6d2f0000 - 0x6d2f8000      C:\dev\Java\jdk1.5.0_05\jre\bin\hpi.dll
    0x76bf0000 - 0x76bfb000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d680000 - 0x6d68c000      C:\dev\Java\jdk1.5.0_05\jre\bin\verify.dll
    0x6d370000 - 0x6d38d000      C:\dev\Java\jdk1.5.0_05\jre\bin\java.dll
    0x6d6a0000 - 0x6d6af000      C:\dev\Java\jdk1.5.0_05\jre\bin\zip.dll
    0x009a0000 - 0x009a7000      C:\dev\IntelliJ\bin\breakgen.dll
    0x6d530000 - 0x6d543000      C:\dev\Java\jdk1.5.0_05\jre\bin\net.dll
    0x71ab0000 - 0x71ac7000      C:\WINDOWS\system32\WS2_32.dll
    0x71aa0000 - 0x71aa8000      C:\WINDOWS\system32\WS2HELP.dll
    0x25fd0000 - 0x25ff1000      C:\WINDOWS\system32\CtxLsp.dll
    0x7c9c0000 - 0x7d1d5000      C:\WINDOWS\system32\SHELL32.dll
    0x77f60000 - 0x77fd6000      C:\WINDOWS\system32\SHLWAPI.dll
    0x773d0000 - 0x774d2000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
    0x5d090000 - 0x5d127000      C:\WINDOWS\system32\comctl32.dll
    0x43000000 - 0x43005000      C:\Program Files\Google\Google Desktop Search\GoogleDesktopNetwork1.dll
    0x77fe0000 - 0x77ff1000      C:\WINDOWS\system32\Secur32.dll
    0x71a50000 - 0x71a8f000      C:\WINDOWS\system32\mswsock.dll
    0x662b0000 - 0x66308000      C:\WINDOWS\system32\hnetcfg.dll
    0x71a90000 - 0x71a98000      C:\WINDOWS\System32\wshtcpip.dll
    0x5ad70000 - 0x5ada8000      C:\WINDOWS\system32\uxtheme.dll
    0x67330000 - 0x6735f000      C:\PROGRA~1\COMMON~1\SYMANT~1\ANTISPAM\asOEHook.dll
    0x7c340000 - 0x7c396000      C:\WINDOWS\system32\MSVCR71.dll
    0x74720000 - 0x7476b000      C:\WINDOWS\system32\MSCTF.dll
    0x63000000 - 0x63014000      C:\WINDOWS\system32\SynTPFcs.dll
    0x77c00000 - 0x77c08000      C:\WINDOWS\system32\VERSION.dll
    0x76fb0000 - 0x76fb8000      C:\WINDOWS\System32\winrnr.dll
    0x76f60000 - 0x76f8c000      C:\WINDOWS\system32\WLDAP32.dll
    0x76f20000 - 0x76f47000      C:\WINDOWS\system32\DNSAPI.dll
    0x751d0000 - 0x751ee000      C:\WINDOWS\system32\wshbth.dll
    0x77920000 - 0x77a13000      C:\WINDOWS\system32\SETUPAPI.dll
    0x27e40000 - 0x27e5a000      C:\WINDOWS\system32\CtxNsp.dll
    0x76fc0000 - 0x76fc6000      C:\WINDOWS\system32\rasadhlp.dll
    0x6d660000 - 0x6d666000      C:\dev\Java\jdk1.5.0_05\jre\bin\rmi.dll
    0x27e70000 - 0x27e98000      C:\WINDOWS\system32\rsaenh.dll
    0x769c0000 - 0x76a73000      C:\WINDOWS\system32\USERENV.dll
    0x5b860000 - 0x5b8b4000      C:\WINDOWS\system32\netapi32.dll
    0x6d550000 - 0x6d559000      C:\dev\Java\jdk1.5.0_05\jre\bin\nio.dll
    VM Arguments:
    jvm_args: -Xmx512000000 -Daternity.home=C:/Projects/1.0/system/system/PlatformInvoker -Didea.launcher.port=7538 -Didea.launcher.library=C:\dev\IntelliJ\bin\breakgen.dll -Dfile.encoding=windows-1252
    java_command: com.intellij.rt.execution.application.AppMain com.aternity.system.platforminvoker.PlatformInvokerMain
    Environment Variables:
    CLASSPATH=C:\dev\IntelliJ\lib\idea.jar;C:\dev\IntelliJ\lib\jdom.jar;C:\dev\IntelliJ\lib\log4j.jar;C:\dev\IntelliJ\lib\openapi.jar;C:\dev\IntelliJ\bin\lax.jar;
    PATH=C:\oracle\product\10.1.0\db_1\bin;C:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;C:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;C:\Program Files\ThinkPad\Utilities;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\ATI Technologies\Fire GL 3D Studio Max;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\IBM ThinkVantage\Client Security Solution
    USERNAME=shachar
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 6, GenuineIntel
    --------------- S Y S T E M ---------------
    OS: Windows XP Build 2600 Service Pack 2
    CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse, sse2
    Memory: 4k page, physical 2096048k(682804k free), swap 4038144k(2524356k free)
    vm_info: Java HotSpot(TM) Server VM (1.5.0_05-b05) for windows-x86, built on Aug 26 2005 15:10:30 by "java_re" with MS VC++ 6.0

    Looks like your VM crashes while attempting to report an error during a select() call. It's quite likely you're doing something wrong there so sharing the relevant bit of code will be helpful. You're right that you sholdnt be able to crash a VM though, try other VMs and see if different behaviour occurs on different VMs.

Maybe you are looking for

  • Uninstall CS6 etc...

    Hello, Further to my previous post regarding registration, licence issues acknowledged by Adobe, I have uninstalled my full copy of CS6 Extended. I would like to know, before re-installing the software, if this is going to cause any further problems

  • Selecting from LIKP, LIPS & VBUK

    Will FOR ALL ENTRIES make the below SELECT faster?   SELECT kvbeln  sposnr  kerdat klfart k~cmfre AS erdat_d02            khandle ktsegfl k~sdabw            slfimg  svrkme  svgbel svgpos s~komkz            ucmgst  svolum  svoleh ktrspg kernam  ktddat

  • Yosemite cannot be downloaded/installed?

    I realize I am running an old MacBook. It still works perfectly, but apparently it has outlived its OS once again. This is what I have: Mac OS X version 10.6.8 Model Name: MacBook   Model Identifier: MacBook4,1   Processor Name: Intel Core 2 Duo   Pr

  • Transfer pictures and video wirelessly as they are taken to a PC. Wireless USB or Bluetooth or WiFi.

     I have an application at work where we need to do this with a point and shoot camera as well as camcorder.  Wireless USB or WiFi would all work. The wireless network here has WEP security login as well.  HELP!

  • CS5 Best print quality using "Image" options ?

    Hi. I have recently upgraded CS5 from 32 bit to 64 using Windows 7. I am trying to maximise print qualty. But notice that "Image" menu only offers 8,16 and 32 bit. The menu is preselected to 8 bit (? Improted picture qualtiy) and if I reselect to 32