Private: Send the STDIN stream for the Nail to read from.

 io = nil - an IO of the stdin stream to send.
769515
def send_stdin(io = nil)
      unless io.nil?
        begin
          send_chunk :stdin, io.read(2048)
        end until io.eof?
        io.close
      end
      send_chunk :stdin_eof
    end
503441
def write(self):
        

        # get_chunk may sometimes return bytes, and sometimes return strings
        # because of the nature of the different types of STDIN objects we
        # support
        try:
            chunk = self.get_chunk()
            if chunk is None:
                raise DoneReadingForever

        except DoneReadingForever:
            self.log.debug("done reading")

            if self.tty_in:
                # EOF time
                try:
                    char = termios.tcgetattr(self.stream)[6][termios.VEOF]
                except:
                    char = chr(4).encode()

                # normally, one EOF should be enough to signal to an program
                # that is read()ing, to return 0 and be on your way.  however,
                # some programs are misbehaved, like python3.1 and python3.2.
                # they don't stop reading sometimes after read() returns 0.
                # this can be demonstrated with the following program:
                #
                # import sys
                # sys.stdout.write(sys.stdin.read())
                #
                # then type 'a' followed by ctrl-d 3 times.  in python
                # 2.6,2.7,3.3,3.4,3.5,3.6, it only takes 2 ctrl-d to terminate.
                # however, in python 3.1 and 3.2, it takes all 3.
                #
                # so here we send an extra EOF along, just in case.  i don't
                # believe it can hurt anything
                os.write(self.stream, char)
                os.write(self.stream, char)

            return True

        except NotYetReadyToRead:
            self.log.debug("received no data")
            return False

        # if we're not bytes, make us bytes
        if IS_PY3 and hasattr(chunk, "encode"):
            chunk = chunk.encode(self.encoding)

        for proc_chunk in self.stream_bufferer.process(chunk):
            self.log.debug("got chunk size %d: %r", len(proc_chunk),
                    proc_chunk[:30])

            self.log.debug("writing chunk to process")
            try:
                os.write(self.stream, proc_chunk)
            except OSError:
                self.log.debug("OSError writing stdin chunk")
                return True
1218922
def _sendline(self, line):
        
        logging.info('%s: sending line', self.port)
        # clear buffer
        self._lines = []
        try:
            self._read()
        except socket.error:
            logging.debug('%s: Nothing cleared', self.port)

        print 'sending [%s]' % line
        self._write(line + '\r\n')

        # wait for write to complete
        time.sleep(0.1)
1371939
def send_line(self, line, ending=None):
        
        if ending is None:
            ending = self.LINE_ENDING
        return self.send(line + ending)
787416
def paste(_ = nil)
      data = +""
      if 0 != User32.open( 0 )
        hclip = User32.get( CF_UNICODETEXT )
        if hclip && 0 != hclip
          pointer_to_data = Kernel32.lock( hclip )
          # Windows Unicode is ended by two null bytes, so get the whole string
          size = Kernel32.size( hclip )
          data << pointer_to_data.get_bytes( 0, size - 2 )
          data.force_encoding("UTF-16LE")
          Kernel32.unlock( hclip )
        end
        User32.close( )
      end
      data
    end
487325
def recv_io(klass = IO, negotiate = true)
      write("pass IO") if negotiate
      io = @io.recv_io(klass)
      write("got IO") if negotiate
      return io
    end
1363184
def send_line(self, data, nowait=False):
        """"""
        data = data.replace('\n', ' ').replace('\r', ' ')
        f = asyncio.Future(loop=self.loop)
        if self.queue is not None and nowait is False:
            self.queue.put_nowait((f, data))
        else:
            self.send(data.replace('\n', ' ').replace('\r', ' '))
            f.set_result(True)
        return f
1013766
def read(self, count=1024):
            # By default we choose a rather small chunk size, because reading
            # big amounts of input at once, causes the event loop to process
            # all these key bindings also at once without going back to the
            # loop. This will make the application feel unresponsive.
        
        if self.closed:
            return b''

        # Note: the following works better than wrapping `self.stdin` like
        #       `codecs.getreader('utf-8')(stdin)` and doing `read(1)`.
        #       Somehow that causes some latency when the escape
        #       character is pressed. (Especially on combination with the `select`.)
        try:
            data = os.read(self.stdin_fd, count)

            # Nothing more to read, stream is closed.
            if data == b'':
                self.closed = True
                return ''
        except OSError:
            # In case of SIGWINCH
            data = b''

        return self._stdin_decoder.decode(data)
1358461
def write str
      self.class.stream.tap do |stream|
        stream.write str
        stream.flush
      end ; nil
    end
535923
function stream(opts) {
  opts = lo.isObject(opts) ? opts : {}
  config.input = opts.input || process.stdin
  config.output = opts.output || process.stdout
}
456545
def call( field_predicate, value, field = nil )
      unless respond_to? field_predicate
        define_name_predicate field_predicate, value, field
      end
      send field_predicate, value
    end
521360
function stream (input, value) {
  value.on('data', data => input.push(data))
  value.on('error', err => error(input, err))
  value.on('end', () => input.push(null))
}
780055
def a_send_line(text, ctx):
    """"""
    if hasattr(text, '__iter__'):
        try:
            ctx.ctrl.sendline(text.next())
        except StopIteration:
            ctx.finished = True
    else:
        ctx.ctrl.sendline(text)
    return True
310961
def receive(max_len=nil)
      max_len ||= 1024

      begin
        data = @socket.recv(max_len)
      rescue IO::WaitReadable
        @logger.logv 'Retrying receive...'
        IO.select([@socket])
        retry
      rescue Exception => e
        if e.class != 'IOError' && e.message != 'closed stream'
          @logger.log_exception(e, 'EXCEPTION during receive!')
        end
      end

      if (data.nil? || data.empty?)
        @logger.log "Client #{@socket.inspect} disconnected!"
        data = ''
      else
        @logger.log "Received #{data.length} bytes"
      end

      return data
    end
1155075
public void sendfile(OutputStream os, long offset, long length)
    throws IOException
  {
    if (os instanceof OutputStreamWithBuffer) {
      writeToStream((OutputStreamWithBuffer) os);
    }
    else {
      writeToStream(os);
    }
  }
281049
def send_pid(cls, sock, pid):
    """"""
    assert(isinstance(pid, IntegerForPid) and pid > 0)
    encoded_int = cls.encode_int(pid)
    cls.write_chunk(sock, ChunkType.PID, encoded_int)
1374295
def send_chunk(type, content = nil)
      chunk = Chunk.new(type, content).to_s
      socket.write chunk
    end