This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with SelectionKey OP_CONNECT


Stanley Brown wrote:

Hello,

I have noticed a difference between gcj and Sun's implementation of NIO socket channels. GCJ is not setting the readyOps when a socket is connectable. I wrote an example program to illustrate the problem:


Hi Stanley,

Could you post a bug report with this test case at gcc.gnu.org/bugzilla? Also, please post a context diff (-c or -u) with the bug report, as the patch you posted is difficult to read.

Thanks

Bryce


-------------------------
import java.net.InetSocketAddress;
import java.nio.channels.*;
import java.util.Iterator;

public class TestConnect
{
   public TestConnect()
   {
       try
       {
           Selector selector = Selector.open();
           SocketChannel channel = SocketChannel.open();
           channel.configureBlocking(false);
           channel.connect(new InetSocketAddress("gcc.gnu.org", 80));
           channel.register(selector, SelectionKey.OP_CONNECT);
                     while (true)
           {
               selector.select();
               Iterator it = selector.selectedKeys().iterator();
                     while (it.hasNext())
               {
                   SelectionKey selKey = (SelectionKey)it.next();
                                     if (selKey.isConnectable())
                   {
                       System.out.println("Connection ready");
                       System.exit(0);
                   }
               }
           }
       }
       catch (Exception ex)
       {
           ex.printStackTrace();
       }
   }
     public static void main(String[] args)
   {
       new TestConnect();
   }
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]