Package java.nio.channels

Examples of java.nio.channels.DatagramChannel.configureBlocking()


                if( ch.socket().getTrafficClass() != cfg.getTrafficClass() )
                {
                    ch.socket().setTrafficClass( cfg.getTrafficClass() );
                }

                ch.configureBlocking( false );
                ch.socket().bind( req.address );
                ch.register( selector, SelectionKey.OP_READ, req );
                synchronized( channels )
                {
                    channels.put( req.address, ch );
View Full Code Here


                if( ch.socket().getTrafficClass() != cfg.getTrafficClass() )
                {
                    ch.socket().setTrafficClass( cfg.getTrafficClass() );
                }

                ch.configureBlocking( false );
                ch.socket().bind( req.address );
                if( req.address == null || req.address.getPort() == 0 )
                {
                    req.address = ( InetSocketAddress ) ch.socket().getLocalSocketAddress();
                }
View Full Code Here

     * @tests DatagramChannel#socket()
     */
    public void test_socket_IllegalBlockingModeException() throws Exception {
        // regression test for Harmony-1036
        DatagramChannel channel = DatagramChannel.open();
        channel.configureBlocking(false);
        DatagramSocket socket = channel.socket();
        try {
            socket.send(null);
            fail("should throw IllegalBlockingModeException");
        } catch (IllegalBlockingModeException e) {
View Full Code Here

        DatagramChannel channel = (DatagramChannel)getChannel();

        synchronized (channel.blockingLock()) {
            boolean oldBlocking = channel.isBlocking();

            channel.configureBlocking(false);

            try {
                return doReceiveTuple(runtime, length);

            } finally {
View Full Code Here

            try {
                return doReceiveTuple(runtime, length);

            } finally {
                channel.configureBlocking(oldBlocking);
            }
        }
    }

    private static class ReceiveTuple {
View Full Code Here

    final SocketAddress OutAddress = new InetSocketAddress(Hostname, OutPort);
    final byte[] Message = "hello, world!".getBytes();

    DatagramChannel out = DatagramChannel.open();
    try {
      out.configureBlocking(false);
      out.socket().bind(OutAddress);
      if (! send) out.connect(InAddress);
   
      DatagramChannel in = DatagramChannel.open();
      try {
View Full Code Here

      out.socket().bind(OutAddress);
      if (! send) out.connect(InAddress);
   
      DatagramChannel in = DatagramChannel.open();
      try {
        in.configureBlocking(false);
        in.socket().bind(InAddress);

        Selector selector = Selector.open();
        try {
          SelectionKey outKey = out.register
View Full Code Here

        // ChannelHandler
        Dispatcher dispatcher = new Dispatcher();

        ChannelHandler channelHandler = new TestChannelHandler();
        DatagramChannel channel = DatagramChannel.open();
        channel.configureBlocking(false);
        dispatcher.registerChannel(channel, channelHandler);

        // to get access to the HandlerAdapter we need to break open the
        // Dispatcher so that we can access the created HandlerAdapter over the
        // selector field.
View Full Code Here

    protected DatagramChannel open(SocketAddress localAddress) throws Exception {
        final DatagramChannel c = DatagramChannel.open();
        boolean success = false;
        try {
            new NioDatagramSessionConfig(c).setAll(getSessionConfig());
            c.configureBlocking(false);
            c.socket().bind(localAddress);
            c.register(selector, SelectionKey.OP_READ);
            success = true;
        } finally {
            if (!success) {
View Full Code Here

    private static DatagramChannel createDatagramChannel(final SocketAddress sockAddr, final boolean blocking) {
        final DatagramChannel ch;
        try {
            ch = DatagramChannel.open();
            ch.configureBlocking(blocking);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        try {
            ch.socket().setBroadcast(false);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.