Examples of FileDescriptor


Examples of java.io.FileDescriptor

     * throws an IOException indicating what went wrong.
     */

    private synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
        try {
      FileDescriptor fd = acquireFD();
      try {
          socketConnect(address, port, timeout);
          /* socket may have been closed during poll/select */
          synchronized (fdLock) {
              if (closePending) {
View Full Code Here

Examples of java.io.FileDescriptor

    /**
     * Accepts connections.
     * @param s the connection
     */
    protected synchronized void accept(SocketImpl s) throws IOException {
  FileDescriptor fd = acquireFD();
  try {
      socketAccept(s);
  } finally {
      releaseFD();
  }
View Full Code Here

Examples of java.io.FileDescriptor

      this.someElement = null;

      this.someTimestamp = new Timestamp(System.currentTimeMillis());
     
      this.someArrayList = new ArrayList();
      this.someArrayList.add(new FileDescriptor());
     
      this.someFileDescriptor = new FileDescriptor();
     
      this.someNullObject = null;
   }
View Full Code Here

Examples of java.io.FileDescriptor

    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);

            if (!new File(filePath).exists()) {
                throw new FileNotFoundException(path);
            }
           
            JarFile jf = new JarFile(filePath);
            ZipEntry zf = jf.getEntry(internalPath);

            if(zf == null) {
                throw new FileNotFoundException(path);
            }

            InputStream is = jf.getInputStream(zf);
            // FIXME: don't use RubyIO for this
            return new ChannelDescriptor(Channels.newChannel(is), RubyIO.getNewFileno(), flags, new FileDescriptor());
        } else {
            JRubyFile theFile = JRubyFile.create(cwd,path);

            if (theFile.isDirectory() && flags.isWritable()) {
                throw new DirectoryAsFileException();
View Full Code Here

Examples of java.io.FileDescriptor

                }
            }

            socket_address = new InetSocketAddress(addr, portInt);
            ssc.socket().bind(socket_address);
            initSocket(context.getRuntime(), new ChannelDescriptor(ssc, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
        } catch (InvalidValueException ex) {
            throw context.getRuntime().newErrnoEINVALError();
        } catch(UnknownHostException e) {
            throw sockerr(context.getRuntime(), "initialize: name or service not known");
        } catch(BindException e) {
View Full Code Here

Examples of java.io.FileDescriptor

                            connected.configureBlocking(false);
                            connected.configureBlocking(true);
                        }
       
                        // otherwise one key has been selected (ours) so we get the channel and hand it off
                        socket.initSocket(context.getRuntime(), new ChannelDescriptor(connected, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
                    } catch (InvalidValueException ex) {
                        throw context.getRuntime().newErrnoEINVALError();
                    }
                    return socket;
                }
View Full Code Here

Examples of java.io.FileDescriptor

                // no connection immediately accepted, let them try again
                throw context.getRuntime().newErrnoEAGAINError("Resource temporarily unavailable");
            } else {
                try {
                    // otherwise one key has been selected (ours) so we get the channel and hand it off
                    socket.initSocket(context.getRuntime(), new ChannelDescriptor(ssc.accept(), RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
                } catch (InvalidValueException ex) {
                    throw context.getRuntime().newErrnoEINVALError();
                }
                return socket;
            }
View Full Code Here

Examples of java.io.FileDescriptor

                channel = SocketChannel.open();
            } else if(soType == SOCK_DGRAM) {
                channel = DatagramChannel.open();
            }
           
            initSocket(context.getRuntime(), new ChannelDescriptor(channel, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
        } catch (InvalidValueException ex) {
            throw context.getRuntime().newErrnoEINVALError();
        } catch(IOException e) {
            throw sockerr(context.getRuntime(), "initialize: " + e.toString());
        }
View Full Code Here

Examples of java.io.FileDescriptor

    @JRubyMethod(visibility = Visibility.PRIVATE)
    public IRubyObject initialize(ThreadContext context) {
        try {
            DatagramChannel channel = DatagramChannel.open();
            initSocket(context.getRuntime(), new ChannelDescriptor(channel, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
        } catch (org.jruby.util.io.InvalidValueException ex) {
            throw context.getRuntime().newErrnoEINVALError();
        } catch (ConnectException e) {
            throw context.getRuntime().newErrnoECONNREFUSEDError();
        } catch (UnknownHostException e) {
View Full Code Here

Examples of java.io.FileDescriptor

   
    public RubyFile(Ruby runtime, String path, InputStream in) {
        super(runtime, runtime.getFile());
        this.path = path;
        try {
            this.openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(in), getNewFileno(), new FileDescriptor())));
        } catch (InvalidValueException ex) {
            throw runtime.newErrnoEINVALError();
        }
        this.openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags());
        registerDescriptor(openFile.getMainStream().getDescriptor());
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.