Package java.nio.channels

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


            SocketAddress destination = req.getDestination();
            if (destination == null) {
                destination = session.getRemoteAddress();
            }

            int writtenBytes = ch.send(buf.buf(), destination);

            if (writtenBytes == 0) {
                // Kernel buffer is full
                key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
            } else if (writtenBytes > 0) {
View Full Code Here


            if (channel instanceof DatagramChannel) {
                DatagramChannel dchannel = (DatagramChannel)channel;
                //were using a shared channel, document says its thread safe
                //TODO check optimization, one channel per thread?
                while ( total < command.length ) {
                    total += dchannel.send(buf, udpaddr);
                }
            } else {
                while ( total < command.length ) {
                    total += channel.write(buf);
                }
View Full Code Here

            if (channel instanceof DatagramChannel) {
                DatagramChannel dchannel = (DatagramChannel)channel;
                //were using a shared channel, document says its thread safe
                //TODO check optimization, one channel per thread?
                while ( total < command.length ) {
                    total += dchannel.send(buf, udpaddr);
                }
            } else {
                while ( total < command.length ) {
                    total += channel.write(buf);
                }
View Full Code Here

    }
  }

  private void send(byte[] queryBytes, SocketAddress host) throws IOException {
    DatagramChannel datagramChannel = multiUDPReceiver.getDatagramChannel();
    datagramChannel.send(ByteBuffer.wrap(queryBytes), host);
  }
}
View Full Code Here

            if( destination == null )
            {
                destination = session.getRemoteAddress();
            }

            int writtenBytes = ch.send( buf.buf(), destination );

            if( writtenBytes == 0 )
            {
                // Kernel buffer is full
                key.interestOps( key.interestOps() | SelectionKey.OP_WRITE );
View Full Code Here

                               "\n     position:" + data.position() +
                               "\n        limit:" + data.limit() +
                               "\n     capacity:" + data.capacity() +
                               " bytes on DG channel to " + sa);
            try {
                int n = dgChannel.send(data, sa);
                System.out.println("DG_Sent " + n + " bytes");
            } catch (IOException e) {
                //This regression test is to check vm crash only, so ioe is OK.
                e.printStackTrace();
            }
View Full Code Here

                SocketAddress destination = req.getDestination();
                if (destination == null) {
                    destination = session.getRemoteAddress();
                }
   
                int localWrittenBytes = ch.send(buf.buf(), destination);
                writtenBytes += localWrittenBytes;
   
                if (localWrittenBytes == 0 || writtenBytes >= maxWrittenBytes) {
                    // Kernel buffer is full or wrote too much
                    key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
View Full Code Here

            {
                continue;
            }

            int pos = buf.position();
            int writtenBytes = ch
                    .send( buf.buf(), session.getRemoteAddress() );

            if( writtenBytes == 0 )
            {
                // Kernel buffer is full
View Full Code Here

                session.increaseWrittenWriteRequests();
                session.getManagerFilterChain().dataWritten( session, marker );
                continue;
            }

            int writtenBytes = ch
                    .send( buf.buf(), session.getRemoteAddress() );

            SelectionKey key = session.getSelectionKey();
            if( writtenBytes == 0 )
            {
View Full Code Here

            if( !key.isValid() )
            {
                continue;
            }

            int writtenBytes = ch
                    .send( buf.buf(), session.getRemoteAddress() );

            if( writtenBytes == 0 )
            {
                // Kernel buffer is full
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.