Package java.nio.channels

Examples of java.nio.channels.Channel


     * @throws java.io.IOException if there is an exception during IO
     */
    public static ChannelDescriptor open(String cwd, String path, ModeFlags flags, int perm, POSIX posix) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException {
        boolean fileCreated = false;
        if (path.equals("/dev/null") || path.equalsIgnoreCase("nul:") || path.equalsIgnoreCase("nul")) {
            Channel nullChannel = new NullChannel();
            // FIXME: don't use RubyIO for this
            return new ChannelDescriptor(nullChannel, RubyIO.getNewFileno(), flags, new FileDescriptor());
        } else if(path.startsWith("file:")) {
            String filePath = path.substring(5, path.indexOf("!"));
            String internalPath = path.substring(path.indexOf("!") + 2);
View Full Code Here


        }
       
        if (!openFile.isReadable()) {
            close();
        } else {
            Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
            if (socketChannel instanceof SocketChannel
                    || socketChannel instanceof DatagramChannel) {
                try {
                    asSocket().shutdownOutput();
                } catch (IOException e) {
View Full Code Here

        if (!openFile.isWritable()) {
            close();
        } else {
            if(openFile.getPipeStream() != null) {
                Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
                if (socketChannel instanceof SocketChannel
                    || socketChannel instanceof DatagramChannel) {
                    try {
                        asSocket().shutdownInput();
                    } catch (IOException e) {
View Full Code Here

          throw context.getRuntime().newSystemCallError(e.getMessage());
      }
    }

    protected InetSocketAddress getLocalSocket() {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if (socketChannel instanceof SocketChannel) {
            return (InetSocketAddress)((SocketChannel)socketChannel).socket().getLocalSocketAddress();
        } else if (socketChannel instanceof ServerSocketChannel) {
            return (InetSocketAddress)((ServerSocketChannel) socketChannel).socket().getLocalSocketAddress();
        } else if (socketChannel instanceof DatagramChannel) {
View Full Code Here

            return null;
        }
    }

    protected InetSocketAddress getRemoteSocket() {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if(socketChannel instanceof SocketChannel) {
            return (InetSocketAddress)((SocketChannel)socketChannel).socket().getRemoteSocketAddress();
        } else {
            return null;
        }
View Full Code Here

            return null;
        }
    }

    private Socket asSocket() {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if(!(socketChannel instanceof SocketChannel)) {
            throw getRuntime().newErrnoENOPROTOOPTError();
        }

        return ((SocketChannel)socketChannel).socket();
View Full Code Here

        return ((SocketChannel)socketChannel).socket();
    }

    private ServerSocket asServerSocket() {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if(!(socketChannel instanceof ServerSocketChannel)) {
            throw getRuntime().newErrnoENOPROTOOPTError();
        }

        return ((ServerSocketChannel)socketChannel).socket();
View Full Code Here

        return ((ServerSocketChannel)socketChannel).socket();
    }

    private DatagramSocket asDatagramSocket() {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if(!(socketChannel instanceof DatagramChannel)) {
            throw getRuntime().newErrnoENOPROTOOPTError();
        }

        return ((DatagramChannel)socketChannel).socket();
View Full Code Here

        return ((DatagramChannel)socketChannel).socket();
    }

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

        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        return trueFalse(runtime, (socketChannel instanceof DatagramChannel) ? asDatagramSocket().getBroadcast() : false);
    }

    private void setBroadcast(IRubyObject val) throws IOException {
        Channel socketChannel = openFile.getMainStream().getDescriptor().getChannel();
        if(socketChannel instanceof DatagramChannel) {
            asDatagramSocket().setBroadcast(asBoolean(val));
        }
    }
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.