Package java.nio.channels

Examples of java.nio.channels.Channel


                         (socketChannel instanceof SocketChannel) ? asSocket().getOOBInline() : false
                         );
    }

    private IRubyObject getRcvBuf(Ruby runtime) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return number(runtime,
                      (socketChannel instanceof SocketChannel) ? asSocket().getReceiveBufferSize() :
                      ((socketChannel instanceof ServerSocketChannel) ? asServerSocket().getReceiveBufferSize() :
                       asDatagramSocket().getReceiveBufferSize())
                      );
View Full Code Here


                       asDatagramSocket().getReceiveBufferSize())
                      );
    }

    private IRubyObject getSndBuf(Ruby runtime) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return number(runtime,
                      (socketChannel instanceof SocketChannel) ? asSocket().getSendBufferSize() :
                      ((socketChannel instanceof DatagramChannel) ? asDatagramSocket().getSendBufferSize() : 0)
                      );
    }
View Full Code Here

                      ((socketChannel instanceof DatagramChannel) ? asDatagramSocket().getSendBufferSize() : 0)
                      );
    }

    private IRubyObject getReuseAddr(Ruby runtime) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return trueFalse(runtime,
                         (socketChannel instanceof ServerSocketChannel) ? asServerSocket().getReuseAddress() : false
                         );
    }
View Full Code Here

                         (socketChannel instanceof ServerSocketChannel) ? asServerSocket().getReuseAddress() : false
                         );
    }

    private IRubyObject getTimeout(Ruby runtime) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return number(runtime,
                      (socketChannel instanceof SocketChannel) ? asSocket().getSoTimeout() :
                      ((socketChannel instanceof ServerSocketChannel) ? asServerSocket().getSoTimeout() :
                       ((socketChannel instanceof DatagramChannel) ? asDatagramSocket().getSoTimeout() : 0))
                      );
View Full Code Here

    protected int getSoTypeDefault() {
        return 0;
    }

    private IRubyObject getSoType(Ruby runtime) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return number(runtime,
                      (socketChannel instanceof SocketChannel) ? RubySocket.SOCK_STREAM :
                      ((socketChannel instanceof ServerSocketChannel) ? RubySocket.SOCK_STREAM :
                       ((socketChannel instanceof DatagramChannel) ? RubySocket.SOCK_DGRAM : getSoTypeDefault()))
                      );
View Full Code Here

           
            if (descriptor == null) {
                throw ruby.newErrnoEBADFError();
            }
           
            Channel mainChannel = descriptor.getChannel();

            if (mainChannel instanceof SocketChannel) {
                // ok, it's a socket...set values accordingly
                // just using AF_INET since we can't tell from SocketChannel...
                socket.soDomain = AF_INET;
View Full Code Here

    public boolean selectForAccept(RubyIO io) {
        return select(io, SelectionKey.OP_ACCEPT);
    }
   
    public boolean select(RubyIO io, int ops) {
        Channel channel = io.getChannel();
       
        if (channel instanceof SelectableChannel) {
            SelectableChannel selectable = (SelectableChannel)channel;
           
            synchronized (selectable.blockingLock()) {
View Full Code Here

            iowait.cancel();
        }
    }
    private volatile BlockingIO.Condition blockingIO = null;
    public boolean waitForIO(ThreadContext context, RubyIO io, int ops) {
        Channel channel = io.getChannel();

        if (!(channel instanceof SelectableChannel)) {
            return true;
        }
        try {
View Full Code Here

        return 1;
    }
   
    public synchronized void ftruncate(long newLength) throws IOException,
            BadDescriptorException, InvalidValueException {
        Channel ch = descriptor.getChannel();
        if (!(ch instanceof FileChannel)) {
            throw new InvalidValueException();
        }
        invalidateBuffer();
        FileChannel fileChannel = (FileChannel)ch;
View Full Code Here

        openFile.setMode(modes.getOpenFileFlags() | OpenFile.SYNC);
        openFile.setProcess(process);

        try {
            if (openFile.isReadable()) {
                Channel inChannel;
                if (process.getInput() != null) {
                    // NIO-based
                    inChannel = process.getInput();
                } else {
                    // Stream-based
                    inChannel = Channels.newChannel(process.getInputStream());
                }
               
                ChannelDescriptor main = new ChannelDescriptor(
                        inChannel,
                        getNewFileno(),
                        new FileDescriptor());
                main.setCanBeSeekable(false);
               
                openFile.setMainStream(new ChannelStream(getRuntime(), main));
                registerDescriptor(main);
            }
           
            if (openFile.isWritable()) {
                Channel outChannel;
                if (process.getOutput() != null) {
                    // NIO-based
                    outChannel = process.getOutput();
                } else {
                    outChannel = Channels.newChannel(process.getOutputStream());
View Full Code Here

TOP

Related Classes of java.nio.channels.Channel

Copyright © 2018 www.massapicom. 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.