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();

Similar Messages

  • Using nio, read method return 0 when readable key was selected.

    I'm so sorry for my ugly English. -_-;;
    Our server(that was designed by me).
    read method return 0 continuously. when readble key was selected.
    So the code fallen into infinite loop. and the server was hanged.
    How can i solve this problem?

    Best to eliminate the most obvious possibilities first. Next question is which JDK are you using? There were bugs in this area in 1.4.0 and 1.4.1.

  • Bug? EJB method Return Value and Client Catch the Exception?

    oc4j 9.0.3 on the windows 2000
    I write a Stateless Session Bean named SB1 ,
    and define application exception.
    The Code as follow:
    public class AppErrorException extends Exception
    public interface SB1 extends EJBObject
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws RemoteException, AppErrorException;
    public class SB1Bean implements SessionBean
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws RemoteException, AppErrorException
    throw new AppErrorException("Error in getMemono");
    public class SB1TestClient
    try
    memomo= sb1.getMemono(.....);
    catch(AppErrorException ae)
    ae.printStackTrace();
    I found a bug.
    If SB1.getMemono() throws the AppErrorException, but SB1TestClient will not catch any Exception.
    It is not normal!!!!
    [cf]
    But If I convert "public String getMemono(...)" into "public void getMemono(...)",
    When SB1.getMemono() throws the AppErrorException, but SB1TestClient will catch any Exception.
    It is normal.

    getMemono(.......)'s code as follow:
    public String getMemono(String sysID, String rptKind, String parentMemono)
    throws AppErrorException
    log("getMemono("+sysID+", "+rptKind+", "+parentMemono+")");
    Connection connection= null;
    CallableStatement statement = null;
    String memono= "";
    short retCode= -1;
    String retMsg= "";
    try
    String sql= this.CALL_SPGETMEMONO;
    connection = ResourceAssistant.getDBConnectionLocal("awmsDS");
    statement= connection.prepareCall(sql);
    statement.setString(1, sysID.trim());
    statement.setString(2, rptKind.trim());
    statement.setString(3, parentMemono.trim());
    statement.registerOutParameter(4, java.sql.Types.VARCHAR);
    statement.registerOutParameter(5, java.sql.Types.SMALLINT);
    statement.registerOutParameter(6, java.sql.Types.VARCHAR);
    statement.executeQuery();
    retCode= statement.getShort(5);
    retMsg= statement.getString(6);
    log("retCode="+retCode);
    log("retMsg="+retMsg);
    if (retCode==AppConfig.SHORT_SP_RETCODE_FAILED)
    log("retCode==AppConfig.SHORT_SP_RETCODE_FAILED");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException(retMsg);
    memono= statement.getString(4);
    log("memono="+memono);
    if (rptKind.trim().length()<6)
    log("rptKind.trim().length()<6");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException("rptKind.trim().length()<6");
    memono= "SS";
    catch (AppErrorException ae)
    log("catch(AppErrorException ae)");
    throw ae;
    //throw new EJBException(ae.getErrMsg());
    catch (Exception e)
    log("catch (Exception e)");
    this.sessionContext.setRollbackOnly();
    throw new AppErrorException(IExceptionConst.ERR_MSG_SYSMEMONO_00000, e.toString());
    //throw new EJBException(IExceptionConst.ERR_MSG_SYSMEMONO_00000+", "+e.toString());
    finally
    log("this.sessionContext.getRollbackOnly()="+this.sessionContext.getRollbackOnly());
    ResourceAssistant.cleanup(connection,statement);
    return memono;

  • Does JMQ 3.5 SP1 Enterprise Edition use Java NIO anywhere?

    Hi,
    I was wondering, does anyone know whether JMQ 3.5 SP1 Enterprise Edition uses Java NIO anywhere?
    Cheers, Andrew

    Yes ...
    java.nio is not used on the client (because it needs to support older
    jdk's), however we do use nio on the broker.
    java.nio is used:
    - in the "channels" support in the shared thread pool to allow
    non-blocking reads
    - we use the various Buffer classes for reading,writing and
    persisting some of our data

  • Java NIO client

    I need to make the server is able to hold about 500 connections and operates on a single thread. The server itself should make all the connections. Where can I find examples of finished implementations?

    I have an example, but it does not work
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.SocketChannel;
    import java.nio.channels.spi.SelectorProvider;
    import java.util.*;
    public class NioClient implements Runnable {
         // The host:port combination to connect to
         private InetAddress hostAddress;
         private String host;
         private int port;
         // The selector we'll be monitoring
         private Selector selector;
         // The buffer into which we'll read data when it's available
         private ByteBuffer readBuffer = ByteBuffer.allocate(8192);
         // A list of PendingChange instances
         private List pendingChanges = new LinkedList();
         // Maps a SocketChannel to a list of ByteBuffer instances
         private Map pendingData = new HashMap();
         // Maps a SocketChannel to a RspHandler
         private Map rspHandlers = Collections.synchronizedMap(new HashMap());
         public NioClient() {
              try {this.selector = this.initSelector();} catch(IOException e){}
         public void connect(String host, int port, RspHandler handler) throws IOException {
              this.hostAddress = hostAddress;
              this.host = host;
              this.port = port;
              this.send("$Hello |".getBytes(), handler);
         public void send(byte[] data, RspHandler handler) throws IOException {
              // Start a new connection
              SocketChannel socket = this.initiateConnection();
              // Register the response handler
              this.rspHandlers.put(socket, handler);
              // And queue the data we want written
              synchronized (this.pendingData) {
                   List queue = (List) this.pendingData.get(socket);
                   if (queue == null) {
                        queue = new ArrayList();
                        this.pendingData.put(socket, queue);
                   queue.add(ByteBuffer.wrap(data));
              // Finally, wake up our selecting thread so it can make the required changes
              this.selector.wakeup();
              handler.waitForResponse();
         public void run() {
              while (true) {
                   try {
                        // Process any pending changes
                        synchronized (this.pendingChanges) {
                             Iterator changes = this.pendingChanges.iterator();
                             while (changes.hasNext()) {
                                  ChangeRequest change = (ChangeRequest) changes.next();
                                  switch (change.type) {
                                  case ChangeRequest.CHANGEOPS:
                                       SelectionKey key = change.socket.keyFor(this.selector);
                                       key.interestOps(change.ops);
                                       break;
                                  case ChangeRequest.REGISTER:
                                       change.socket.register(this.selector, change.ops);
                                       break;
                             this.pendingChanges.clear();
                        // Wait for an event one of the registered channels
                        this.selector.select();
                        // Iterate over the set of keys for which events are available
                        Iterator selectedKeys = this.selector.selectedKeys().iterator();
                        while (selectedKeys.hasNext()) {
                             SelectionKey key = (SelectionKey) selectedKeys.next();
                             selectedKeys.remove();
                             if (!key.isValid()) {
                                  continue;
                             // Check what event is available and deal with it
                             if (key.isConnectable()) {
                                  this.finishConnection(key);
                             } else if (key.isReadable()) {
                                  this.read(key);
                             } else if (key.isWritable()) {
                                  this.write(key);
                   } catch (Exception e) {
                        e.printStackTrace();
         private void read(SelectionKey key) throws IOException {
              SocketChannel socketChannel = (SocketChannel) key.channel();
              // Clear out our read buffer so it's ready for new data
              this.readBuffer.clear();
              // Attempt to read off the channel
              int numRead;
              try {
                   numRead = socketChannel.read(this.readBuffer);
              } catch (IOException e) {
                   // The remote forcibly closed the connection, cancel
                   // the selection key and close the channel.
                   key.cancel();
                   socketChannel.close();
                   return;
              System.out.println("READ");
              if (numRead == -1) {
                   // Remote entity shut the socket down cleanly. Do the
                   // same from our end and cancel the channel.
                   key.channel().close();
                   key.cancel();
                   return;
              // Handle the response
              this.handleResponse(socketChannel, this.readBuffer.array(), numRead);
         private void handleResponse(SocketChannel socketChannel, byte[] data, int numRead) throws IOException {
              // Make a correctly sized copy of the data before handing it
              // to the client
              byte[] rspData = new byte[numRead];
              System.arraycopy(data, 0, rspData, 0, numRead);
              // Look up the handler for this channel
              RspHandler handler = (RspHandler) this.rspHandlers.get(socketChannel);
              // And pass the response to it
              if (handler.handleResponse(rspData)) {
                   // The handler has seen enough, close the connection
                   socketChannel.close();
                   socketChannel.keyFor(this.selector).cancel();
         private void write(SelectionKey key) throws IOException {
              SocketChannel socketChannel = (SocketChannel) key.channel();
              synchronized (this.pendingData) {
                   List queue = (List) this.pendingData.get(socketChannel);
                   // Write until there's not more data ...
                   while (!queue.isEmpty()) {
                        ByteBuffer buf = (ByteBuffer) queue.get(0);
                        socketChannel.write(buf);
                        if (buf.remaining() > 0) {
                             // ... or the socket's buffer fills up
                             break;
                        queue.remove(0);
                   if (queue.isEmpty()) {
                        // We wrote away all data, so we're no longer interested
                        // in writing on this socket. Switch back to waiting for
                        // data.
                        key.interestOps(SelectionKey.OP_READ);
         private void finishConnection(SelectionKey key) throws IOException {
              SocketChannel socketChannel = (SocketChannel) key.channel();
              // Finish the connection. If the connection operation failed
              // this will raise an IOException.
              try {
                   socketChannel.finishConnect();
              } catch (IOException e) {
                   // Cancel the channel's registration with our selector
                   System.out.println(e);
                   key.cancel();
                   return;
              // Register an interest in writing on this channel
              key.interestOps(SelectionKey.OP_WRITE);
         private SocketChannel initiateConnection() throws IOException {
              // Create a non-blocking socket channel
              SocketChannel socketChannel = SocketChannel.open();
              socketChannel.configureBlocking(false);
              // Kick off connection establishment
              socketChannel.connect(new InetSocketAddress(this.host, this.port));
              // Queue a channel registration since the caller is not the
              // selecting thread. As part of the registration we'll register
              // an interest in connection events. These are raised when a channel
              // is ready to complete connection establishment.
              synchronized(this.pendingChanges) {
                   this.pendingChanges.add(new ChangeRequest(socketChannel, ChangeRequest.REGISTER, SelectionKey.OP_CONNECT));
              return socketChannel;
         private Selector initSelector() throws IOException {
              // Create a new selector
              return SelectorProvider.provider().openSelector();
    public class RspHandler {
         private byte[] rsp = null;
         public synchronized boolean handleResponse(byte[] rsp) {
              this.rsp = rsp;
              this.notify();
              return true;
         public synchronized void waitForResponse() {
              while(this.rsp == null) {
                   try {
                        this.wait();
                   } catch (InterruptedException e) {
              System.out.println(new String(this.rsp));
    }          NioClient NioClient = new NioClient();
              Thread t = new Thread(NioClient);
              t.setDaemon(true);
              t.start();
              RspHandler handler = new RspHandler();          
              NioClient.connect("69.28.156.250", 27040, handler);
              NioClient.connect("72.165.61.188", 27040, handler);
              NioClient.connect("208.111.133.84", 27011, handler);
              NioClient.connect("72.165.61.136", 27012, handler);
    Edited by: 915967 on 01.08.2012 7:07

  • 11g bug(?)--AM client methods returning collections

    Hi all,
    I've got an application module with a method returning a collection of view rows, and I've exposed it on my client interface. The problem is that, in the data control palette, the method's return is just an untyped "element"--there's no declarative way of accessing the view row's data, that I can see.
    I've tried setting the "Element Java Type" in the "Edit Client Interface" dialog (after generating a custom view row class and exposing accessors on a VR client interface), but that seems to have no effect. I've tried right-clicking on the "element" node in the DCP and selecting "Edit Definition," but that doesn't seem to do anything either (no editor appears). Is there a way to return a typed collection (or, even better, a ViewObject with all attributes pertaining thereto) from a service method and have valuable stuff appear in the DCP?

    Couple of comments
    - wrong forum, should go to: JDeveloper and OC4J 11g Technology Preview
    - if the method returns rows, or ideally a VO, why can't this be done through a VO directly ?
    Frank

  • Java.lang.StackOverflowError when invoking a method, returning a org.w3c.dom.Document object, on a SessionBean

    Hello,
    I hope someone can help me with this.
    I have a stateless session bean, which is returning a
    org.w3c.dom.Document object. The whole object is getting created
    but at the client side I am getting the following exception:
    java.rmi.RemoteException: ; nested exception is:
    weblogic.rmi.ServerError: A RemoteException occurred in the server method
    - with nested exception:
    [java.lang.StackOverflowError:
    Start server side stack trace:
    java.lang.StackOverflowError
    at java.lang.Exception.<init>(Compiled Code)
    at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetEx
    ception.java:58)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(Compiled Code)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
    at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
    Then multiple occurences of the last few lines followed by
    at org.apache.xerces.dom.ParentNode.writeObject(Compiled Code)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(Compiled Code)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
    at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
    at org.apache.xerces.dom.ParentNode.writeObject(Compiled Code)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(Compiled Code)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObject(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeSpecial(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObject(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObjectWL(Compiled
    Code)
    at weblogic.rmi.extensions.AbstractOutputStream2.writeObject(Compiled
    Code)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_WLSkel.invoke(Compiled
    Code)
    at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(Compiled Code
    at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(Compiled
    Code)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(Compiled Code)
    at weblogic.kernel.ExecuteThread.run(Compiled Code)
    End server side stack trace
    at weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
    ava:76)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_WLStub.getRegionAnalyst
    Data(CMSInterestDataEJBEOImpl_WLStub.java:558)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_ServiceStub.getRegionAn
    alystData(CMSInterestDataEJBEOImpl_ServiceStub.java, Compiled Code)
    at CMSJavaScript.main(CMSJavaScript.java:87)
    The structure of the XML document is
    <Maillist>
         <Region>
              <RegionCode>7</RegionCode>
              <RegionName>Asia Pacific</RegionName>
              <Analyst>
                   <Id>11111</Id>
                   <Name>AAAAAAAAAAAAAAAAA</Name>
              </Analyst>
              <Analyst>
                   <Id>22222</Id>
                   <Name>BBBBBBBBBBBBBBBBBB</Name>
              </Analyst>
         </Region>
    </Maillist>
    If the no. of Anlayst elements are 219, I am getting this error ( the same thing
    is working for less no. of analyst).
    Surprisingly when I access this ejb, by deploying it on my local server instance
    on Win-NT, it works fine. I am getting this
    exception, when the server is running on Sun Solaris.
    The weblogic version is 5.1.
    It will be really helpful if someone can reply to mee ASAP
    Thanks.
    Suren.

    Thanks a lot guys for all that information.
    Rajesh Mirchandani <[email protected]> wrote:
    Suren,
    More info at
    http://edocs.bea.com/wls/docs60/faq/java.html#251197
    Rob Woollen wrote:
    The quick fix is probably to use the -Xss argument on the Solaris JVMto increase the
    thread stack size.
    -- Rob
    Suren wrote:
    Thanks for your quick response.
    But how do we overcome with this?
    I tried to look for some help with this, but if you have any idea,
    can you suggest
    something ?
    Thanks
    Suren.
    Rob Woollen <[email protected]> wrote:
    It looks like the stack is overflowing when your DOM Tree is being
    serialized.
    Perhaps the Solaris JVM has a lower stack size by default.
    -- Rob
    Suren wrote:
    Hello,
    I hope someone can help me with this.
    I have a stateless session bean, which is returning a
    org.w3c.dom.Document object. The whole object is getting created
    but at the client side I am getting the following exception:
    java.rmi.RemoteException: ; nested exception is:
    weblogic.rmi.ServerError: A RemoteException occurred in
    the
    server method
    - with nested exception:
    [java.lang.StackOverflowError:
    Start server side stack trace:
    java.lang.StackOverflowError
    at java.lang.Exception.<init>(Compiled Code)
    at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetEx
    ception.java:58)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(Compiled
    Code)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at java.io.ObjectOutputStream.outputClassFields(CompiledCode)
    at java.io.ObjectOutputStream.defaultWriteObject(CompiledCode)
    Then multiple occurences of the last few lines followed by
    at org.apache.xerces.dom.ParentNode.writeObject(CompiledCode)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(CompiledCode)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at java.io.ObjectOutputStream.outputClassFields(CompiledCode)
    at java.io.ObjectOutputStream.defaultWriteObject(CompiledCode)
    at org.apache.xerces.dom.ParentNode.writeObject(CompiledCode)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Compiled Code)
    at java.io.ObjectOutputStream.invokeObjectWriter(CompiledCode)
    at java.io.ObjectOutputStream.outputObject(Compiled Code)
    at java.io.ObjectOutputStream.writeObject(Compiled Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObject(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeSpecial(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObject(Compiled
    Code)
    at weblogic.common.internal.WLObjectOutputStreamBase.writeObjectWL(Compiled
    Code)
    at weblogic.rmi.extensions.AbstractOutputStream2.writeObject(Compiled
    Code)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_WLSkel.invoke(Compiled
    Code)
    at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(CompiledCode
    at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(Compiled
    Code)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(CompiledCode)
    at weblogic.kernel.ExecuteThread.run(Compiled Code)
    End server side stack trace
    at weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
    ava:76)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_WLStub.getRegionAnalyst
    Data(CMSInterestDataEJBEOImpl_WLStub.java:558)
    at com.ssmb.teams.model.CMSInterestDataEJBEOImpl_ServiceStub.getRegionAn
    alystData(CMSInterestDataEJBEOImpl_ServiceStub.java, Compiled
    Code)
    at CMSJavaScript.main(CMSJavaScript.java:87)
    The structure of the XML document is
    <Maillist>
    <Region>
    <RegionCode>7</RegionCode>
    <RegionName>Asia Pacific</RegionName>
    <Analyst>
    <Id>11111</Id>
    <Name>AAAAAAAAAAAAAAAAA</Name>
    </Analyst>
    <Analyst>
    <Id>22222</Id>
    <Name>BBBBBBBBBBBBBBBBBB</Name>
    </Analyst>
    </Region>
    </Maillist>
    If the no. of Anlayst elements are 219, I am getting this error( the
    same thing
    is working for less no. of analyst).
    Surprisingly when I access this ejb, by deploying it on my local
    server
    instance
    on Win-NT, it works fine. I am getting this
    exception, when the server is running on Sun Solaris.
    The weblogic version is 5.1.
    It will be really helpful if someone can reply to mee ASAP
    Thanks.
    Suren.

  • Selecting between java.io and java.nio

    Hi,
    I'm a bit confused between java.io and java.nio. What sre the major differences between these two?
    In areas are these best applicable?

    The java.nio package improves on the basic Java I/O that was available prior to JDK 1.4.
    It is designed to interoperate more natively with the underlying file handles (sockets, open files etc) to achieve better performance.
    The improvements include true non-blocking I/O, better buffer management, character-set support, channels (similar to Occam's channels) and selectors, and some other ancillery stuff. Most of these classes are designed to be inherently threadsafe.
    There are some examples here:
    http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/index.html
    However, if you are still a beginner with file or network I/O, its better if you start with the simple I/O first. You'll appreciate the NIO improvements better afterwards.

  • The java.nio circus - what a headache

    Hi All
    I've been working now with the java.nio classes for a bit and trying to get a non-blocking client HTTP socket going. The requirement: no 3rd-party code and must either read fully from the socket OR timeout quickly (say 10sec).
    Unfortunately, I haven't been able to find ANY nio code that actually does this. There was one example by a John Z. that came really close, but it hung after a full reading of an HTTP stream because it could not determine if it was done reading or not!
    Anyway, here's my full code. It's very hacky and piecemeal, but i'm just looking for a prototype.
    Here's the main processing loop, cobbled together from a mix of examples on the web, plus my own little flourishes... :)
    public static void createSelector(URL url) throws IOException
    // Create a selector and register two socket channels
    Selector selector = null;
    // Create the selector
    selector = Selector.open();
    SocketChannel sChannel = SocketChannel.open();
    sChannel.configureBlocking(false);
    int port = url.getPort();
    if (port == -1) { port = 80; }
    sChannel.connect(new InetSocketAddress(url.getHost(), port));
    // Before the socket is usable, the connection must be completed
    // by calling finishConnect(), which is non-blocking
    int iTime = 0;
    while (!sChannel.finishConnect())
         if (iTime > 10)
              System.out.println("Timeout!");
              throw new IOException("Connection timed out!");
         iTime++;
    System.out.println("Waiting for connection...");
    try { Thread.sleep(1000); } catch (InterruptedException interex) {}
    // Register the channel with selector, listening for all events
    //sChannel.register(selector, sChannel.validOps());
    sChannel.register(selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ);
    boolean allDone = false;
    while (selector.select(5000) > 0)
    // Get list of selection keys with pending events
    Iterator it = selector.selectedKeys().iterator();
    // Process each key at a time
    while (it.hasNext())
    // Get the selection key
    SelectionKey selKey = (SelectionKey)it.next();
    // Remove it from the list to indicate that it is being processed
    it.remove();
    allDone = processSelectionKey(selKey, url);
    if (allDone) { break; }
    } // while(true)
    if (allDone)
    System.out.println("All done!");
    else
         System.out.println("Timeout!");
    Now, the processSelectionKey method returns a true only if we get a -1 on our read. It looks like this:
    public static boolean processSelectionKey(SelectionKey selKey, URL url) throws IOException
    // Since the ready operations are cumulative,
    // need to check readiness for each operation
    if (selKey.isValid() && selKey.isConnectable())
    // Get channel with connection request
    SocketChannel sChannel = (SocketChannel)selKey.channel();
    //System.out.println("Sending request for "+url.getPath()+" using Connectable stream");
    String request = "GET "+url.getPath()+" \r\n\r\n";
    //System.out.println("Writing request "+request);
    sChannel.write(NonblockSocket.encoder.encode(CharBuffer.wrap(request)));
    //sentRequest = true;
    if (selKey.isValid() && selKey.isReadable())
         System.out.println("Readable key!");
    // Get channel with bytes to read
    SocketChannel sChannel = (SocketChannel)selKey.channel();
    int bytesRead = sChannel.read(buf);
    if (bytesRead == -1)
         return true;
    else
         System.out.println("Read "+bytesRead+" bytes...");
    buf.flip();
    System.out.println(decode(buf));
    buf.clear();
    cbuf.clear();
    OK, now this code does not work. There are a couple of problems with it. First of all, the "GET "+urlpath+" \r\n\r\n" is called a WHOLE BUNCH of times, not the usual once-per-request, as you would expect. But, if I programmatically enforce only one GET, it hangs. Still, it's strange.
    Secondly (and this is the real sticky point), it almost never reads in a full HTTP stream from the server before I get the following UNSETTLING exception during a read from the Channel:
    java.io.IOException: An existing connection was forcibly closed by the remote host
    I usually get either one or two successful reads from a readable channel and then the server disconnects me! NEVER saw this one coming. All in all, has ANYONE been able to use nio for client-side stuff to ANY degree at all? Maybe I'm doing something wrong? Any help would be excellent. BTW I'm running Win2K with JDK1.4.1.
    If I can't get this one to work, maybe I'll check out the new additions to the "old-school" java.net Socket.

    Actually,
    I just wrote a if..then to ignore the null accept.
    Even without using non-blocking connect i got two accepts.
    import java.net.*;
    import java.nio.*;
    import java.nio.channels.*;
    import java.nio.channels.spi.*;
    import java.nio.charset.*;
    import java.io.*;
    import java.util.*;
    * @author Aashish
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    public class NonBlockingServerSocket
         public static void main(String[] args)
              try
                        ServerSocketChannel serv = ServerSocketChannel.open();
                        serv.configureBlocking(false);
                        serv.socket().bind(new InetSocketAddress(33333));
                        System.out.println("bind complete");
                        Selector selector = Selector.open();
                        serv.register(selector,SelectionKey.OP_ACCEPT);
                        while(selector.select() > 0)
                             Iterator iter = selector.selectedKeys().iterator();
                             while(iter.hasNext())
                                  SelectionKey key = (SelectionKey)iter.next();
                                  if(key.isAcceptable())
                                       ServerSocketChannel servChan = (ServerSocketChannel)key.channel();
                                       SocketChannel sockChan = servChan.accept();
                                       if(sockChan == null)
                                            System.out.println("Just got a null channel in accept");
                                       else
                                            System.out.println("just accepted a sockChan");
                                            sockChan.configureBlocking(false);
                                           sockChan.register(selector,SelectionKey.OP_READ);
                                           if(sockChan.isConnected())
                                                 System.out.println("Channel is connected");
                                  if(key.isReadable())
                                                        //something here
              catch (Exception ex)
                   ex.printStackTrace();

  • Socket disconnection event not being reveived java.nio

    Hi All
    My question is as below
    i am using java.nio package + win 2K + jdk1.4.1_02
    I have a Server accepting socket connection and is configured
    in Nonblocking mode.
    -The server receives (selector) events (accept event)
    when a client requests for a connection .
    -The server is getting read and write events when
    client wants to read and write
    -The server gets a read event when the client disconnects
    My only problem is that the Server is not getting any events
    when the client disconnect due to network break down
    for EX when the network connection breaks the client disconnects
    but the server selector is not getting any events
    I am storing the client Socket objects in a Hash Table and
    if i execute the .isConnected() method it returns true
    even though the the client is down
    The only work around is to try to read and write on the socket
    i get an IO exception and am able to make out that the
    client is disconnected
    But this is not desirable for my client
    as client modification to give any kind of echo is not possible and
    a read /write event will cause problem.
    Can any one tell how to detect client side disconnection
    with out Read and Write on the client socket
    I get an socket Exception when the socket is in Blocking IO and is blocked on read/ write but I am facing this problem in NonBlockingIO
    Regards
    Avinash

    int ct = read.selectNow();
    if (ct > 0)
    Set readyKeys = read.selectedKeys();
    Iterator i = readyKeys.iterator();
    while (i.hasNext())
    SelectionKey key = (SelectionKey) i.next();
    i.remove();
    if (key.isReadable())
    SelectableChannel nextReady = (SelectableChannel) key.channel();
    SocketChannel sc = (SocketChannel) key.channel();
    int rd = sc.read(buffer);
    // Link is dead
    if (rd == -1)
    key.cancel();
    key.attach(null);
    nextReady.close();
    continue;
    // Process your data
    catch (Exception e)
    e.printStackTrace();

  • Troubles with timeout using java.nio.channels and non-blocking sockets

    Hello.
    I have a server application that employs java.nio.channels with non-blocking sockets.
    The server waits for connections. The client should connect and be first in sending data.
    Timeouts are significant! If client exceeds the allowed time to send data, the server should break the connection.
    The huge trouble I've discovered that I cannot control the timeout when client connects but remains silent.
    My code looks as follows:
    <pre>
    Selector oSel;
    SocketChannel oSockChan;
    Socket oSock;
    SelectionKey oSelKey;
    Iterator<SelectionKey> oItSelKeys;
    int iCurrState, iMask, iCount;
    iCurrState = INT_SERVER_WORKING;
    iMask = SelectionKey.OP_ACCEPT | SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE;
    while ( iCurrState == INT_SERVER_WORKING )
    try
    *// retrieving next action*
    iCount = oSel.select();
    if ( iCount > 0 )
    oItSelKeys = oSel.selectedKeys().iterator();
    while ( oItSelKeys.hasNext() )
    oSelKey = oItSelKeys.next();
    oItSelKeys.remove();
    if ( oSelKey.isValid() )
    switch ( oSelKey.readyOps() & iMask ) {
    case SelectionKey.OP_ACCEPT :
    oSockChan = oSSockChan.accept();
    oSockChan.configureBlocking(false);
    oSock = oSockChan.socket();
    oSock.setKeepAlive(true);
    oSockChan.register(oSel,SelectionKey.OP_READ,new MyPacket(oSock.getInetAddress(),oSock.getPort()));
    break;
    case SelectionKey.OP_READ :
    oSelKey.interestOps(0);
    ((MyPacket) oSelKey.attachment()).inRequest(); *// preparing request*
    this.getReader().add(oSelKey); *// sending key to reading thread*
    break;
    case SelectionKey.OP_WRITE :
    oSelKey.interestOps(0);
    ((MyRequest) oSelKey.attachment()).inResponse(); *// preparing response*
    this.getWriter().add(oSelKey); *// sending key to writing thread*
    break;
    case SelectionKey.OP_CONNECT :
    default :
    *// nothing to do*
    catch ( IOException oExcept )
    *// do some actions*
    </pre>
    Timeouts are easily controlled by reading and writing threads (see OP_READ and OP_WRITE ).
    But when a client just connects without consequent data send, the state of this connection remains as OP_ACCEPT. The connection remains open for arbitrarily large time and I cannot control it!
    Please help with idea how can I terminate such connections!

    How can I process the keys that weren't selected at the bottom of the loop? Should I use the method keys() ?Yes. Form a new set from keys() and removeAll(selectedKeys()). Do that before you process selectedKeys().
    And the second moment: as I understood a single key may contain several operations simultaneously? Thus I should use several if's (but not if/else 'cause it's the equivalent of switch ... case ).If there is anything unclear about 'your switch statement is invalid. You need an if/else chain' I fail to see what it is. Try reading it again. And if several ifs were really the equivalent of "switch ... case", there wouldn't be a problem in the first place. They're not, and there is.

  • Detect loss of socket connection using java.nio.channels.Selector

    I'm using the nio package to write a "proxy" type application, so I have a ServerSocketChannel listening for incoming connections from a client and then create a SocketChannel to connect to a server. Both SocketChannels are registered to the same Selector for OP_READ requests.
    All works fine, until either the client or server drops the connection. How can I detect this has happened, so my proxy app can drop the other end of the connection ?
    The Selector.select() method is not triggered by this event. I have tried using Selector.select(timeout) and then checking the status of each channel, but they still show isConnected()=true.
    Thanks,
    Phil Blake

    Please don't cross post.
    http://forum.java.sun.com/thread.jsp?thread=184411&forum=4&message=587874

  • Returning XML to client from web service

    Hi,
    I am new to developing web services using JAX_RPC. I am trying to return a xml document to the client from the web service.
    My Server implementation is as follows:
    Interface:
    public interface OntoIF extends Remote
    public DataHandler ontoCompare (String targetUrl,String sourceUrl ) throws RemoteException;
    Implementaion:
    public class OntoImpl implements OntoIF
    public DataHandler ontoCompare (String targetUrl,String sourceUrl ) throws RemoteException
    DataHandler dataHandler = new DataHandler( new StreamSource( new File ("status.xml")), "text/xml");
    return dataHandler;
    Client Implementation:
    Stub stb = (Stub) (new OntoService_Impl().getOntoIFPort());
    stb._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
         "http://localhost:8080/onto-service/onto");
    OntoIF onto = (OntoIF) stb;
    DataHandler retDHandler = onto.ontoCompare(targetOntoUrl, sourceOntoUrl);
    When I compile and run my client, it throws the following error -
    java.rmi.ServerException: JAXRPCSERVLET28: Missing port information
    at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.ja
    va:497)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:294
    at sstub.OntoIF_Stub.echoDataHandler(OntoIF_Stub.java:122)
    at sstub.OntoClient.main(OntoClient.java:63)
    Can you please let me know what I am doing wrong? I have no problems in sending a DataHandler but receiving the DataHandler from the web service throws errors.
    Thanks!

    Hi I'm having the same problem. I try to set up a Web Service using JAX_RPC. My WS should invoke a native Method implemented in C++. Did you got a solution for this issue? My Error Message is as follows:
    java.rmi.ServerException: JAXRPCSERVLET28: Missing port information
         at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:497)
         at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:294)
         at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:80)
         at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:489)
         at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:122)
         at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:86)
    at $Proxy0.getHello(Unknown Source)
         at com.neuhaus.test.ws.client.NativeInvokeClient.main(NativeInvokeClient.java:44)
    Exception in thread "main"
    greetings, JAN

  • Socket seems too slow...maybe java.nio?

    Hello
    In our system I have to receive Multicast Packets repeats very quick(1-5 ms). I have to link them one after an other in the order they sent. And if I miss a packet, something will go wrong...
    I have to listen to different IPs and I use different threads for different IPs. If I use only one thread (and listens to only one IP) everything seems ok.
    But if I starts listening to an other ip too, I miss 2 packets in a row, or only one if I turn off parsing the message (XML).
    Here is the code I use in the Threads:
    try{
                   socket = new MulticastSocket(port);
                   socket.setSoTimeout(1000);
                   inetAddress = InetAddress.getByName(ip);
                   NetworkInterface nInterface=
    NetworkInterface.getByName(networkInterface);
                   if(nInterface!=null)socket.setNetworkInterface(nInterface);
                   socket.joinGroup(inetAddress);
              catch(IOException ioe){
                   logger.error(ioe.getMessage(), ioe);
    return;
              try{
                   while (!interrupted()) {
                        try{
                             byte[] buffer = new byte[1480];
                             packet = new DatagramPacket(buffer, buffer.length);
                             socket.receive(packet);
    parse(buffer);
                        }catch(SocketTimeoutException stoe){
                             //     DO NOTHING
                        }catch(IOException ioe){
                             logger.error(ioe.getMessage(), ioe);
              }finally{
                   try {
                        if(socket!=null){
                             socket.leaveGroup(inetAddress);
                   } catch (IOException ioe) {}
    Every Thread has its own parsing object.
    Any tips, what is wrong?
    Maybe java.nio could solve the problem somehow. There is a sample server in [Java Home]/sample/nio/server and it suggest that there are quicker methods to receive messages from different IPs (maybe Blocking/Pooled-Thread Server). But I can't understand the API and the Sample while I was reading it (20-30 minutes).
    Could it be quicker? Does it worth toying with the idea?
    Thanks:
    Bence

    In our system I have to receive Multicast Packets
    repeats very quick(1-5 ms). I have to link them one
    after an other in the order they sent. And if I miss
    a packet, something will go wrong...There is no guarantee anywhere in the system that you won't miss a datagram. UDP doesn't make such guarantees. If you need all the packets you will have to build ACK or NACK into your protocol.
    You can alleviate the problem by running a very large socket receive buffer. But you can't eliminate it. Rethink this.
    NIO is not significantly quicker for applications like this, it is more scalable.

  • Java NIO's puzzle

    hi,all
    In traditonal thread-pool based programming way,the Server can process multi-clients by thread(time-sharing),all clients's time is equal.
    In Java NIO programming way,the [select] will process multi-clients without thread pool.So,the the second client must be processed after the first client be complished.if the first client is cost much time,other cients must be long time waiting?
    plz help me - thanks for your time
    Tony.
    Hangzhou,china

    As an NIO server in non-blocking mode obviously never blocks (or rather it only blocks in select(), when nothing is happening), it can implement any kind of scheduling it likes between the various SocketChannels it has accepted as connected clients. It isn't obliged in any way to completely finish with one client before starting on the next, and it generally can't do so because data from any particular client doesn't necessarily arrive in a single chunk.

Maybe you are looking for

  • Help setting up port forwarding for Ekiga

    Hi I am trying to set up Ekiga on my Arch X86_64 box but I can't get port forwarding to work on the Thomson TG585v7 wireless router, which I am sharing with a neighbor.  I have tried some how-to's I found via Google and set up Application/Game Sharin

  • Vendor credit memo

    hi all, How to post credit memo for vendor withrespect to PO or Invoice. Rds, Javed

  • ESSBASE + OBIEE Dashboards or OBIEE ADMIN TOOL + OBIEE Dashboards.

    Hi all, Hi all, I am currently working on the proposal for a Financial BI reporting project for a company in the UK and would like to know the advantages of using ( ESSBASE + OBIEE Dashboards) solution over (OBIEE ADMIN TOOL + OBIEE Dashboards). As t

  • PT Transform Tag that outputs Image Server URL

    I noticed something missing from the EDK that I wanted to get Plumtree's perspective on. We have instances where we need the imageserver URI through the facilities of a Transformation Tag. This useful when the portlet source document is native HTML a

  • HDRPro hangs when converting to 16 bit

    Hi all, I'm having an issue here with HDRPro. When I first open CS5 and merge to HDRPro (generally three .NEF raw files) everything is fine. I hit "OK", the file is converted in the HDR dialog, and then after the various operations in the main Photos