Exemple #1
0
  protected void initSocket(Ruby runtime, ChannelDescriptor descriptor) {
    // continue with normal initialization
    openFile = new OpenFile();

    try {
      openFile.setMainStream(
          ChannelStream.fdopen(runtime, descriptor, new ModeFlags(ModeFlags.RDONLY)));
      openFile.setPipeStream(
          ChannelStream.fdopen(runtime, descriptor, new ModeFlags(ModeFlags.WRONLY)));
      openFile.getPipeStream().setSync(true);
    } catch (org.jruby.util.io.InvalidValueException ex) {
      throw runtime.newErrnoEINVALError();
    }
    openFile.setMode(OpenFile.READWRITE | OpenFile.SYNC);
  }
  protected void initSocket(Ruby runtime, ChannelDescriptor descriptor) {
    // continue with normal initialization
    MakeOpenFile();

    try {
      openFile.setMainStream(
          ChannelStream.fdopen(runtime, descriptor, newModeFlags(runtime, ModeFlags.RDONLY)));
      openFile.setPipeStream(
          ChannelStream.fdopen(runtime, descriptor, newModeFlags(runtime, ModeFlags.WRONLY)));
      openFile.getPipeStream().setSync(true);

    } catch (org.jruby.util.io.InvalidValueException ex) {
      throw runtime.newErrnoEINVALError();
    }

    openFile.setMode(OpenFile.READWRITE | OpenFile.SYNC);

    // see rsock_init_sock in MRI; sockets are initialized to binary
    setAscii8bitBinmode();
  }