Writes messages to a socket/host.
168605
def SocketWriter(host, port, af=None, st=None):
    
    import socket
    if af is None:
        af = socket.AF_INET
    if st is None:
        st = socket.SOCK_STREAM
    message = '({0}): {1}'
    s = socket.socket(af, st)
    s.connect(host, port)
    try:
        while True:
            logstr = (yield)
            s.send(logstr)
    except GeneratorExit:
        s.close()
620184
def start
      write_header(@socket, build_header)
      read_header(@socket)
      @thread = Thread.start do
        while @is_running
          data = read_all(@socket)
          msg = @topic_type.new
          msg.deserialize(data)
          @byte_received += data.length
          @msg_queue.push(msg)
        end
      end
    end
1059699
def write_packet(sock, data, already_pickled=False):
    """"""
    if already_pickled:
        sent_data = data
    else:
        sent_data = pickle.dumps(data, PICKLE_HIGHEST_PROTOCOL)
    sent_data = struct.pack("l", len(sent_data)) + sent_data
    nsend = len(sent_data)
    while nsend > 0:
        nsend -= temp_fail_retry(socket.error, sock.send, sent_data)
733060
def _write(self, s):
        
        while s:
            n = self.sslobj.write(s)
            if not n:
                raise IOError('Socket closed')
            s = s[n:]
843875
def write(self, message):
        

        self.__thread_local_ctx.write_count += 1

        try:
            if self.__thread_local_ctx.write_count > 1:
                return

            # For each line in the buffer ending with \n, output that line to
            # the logger
            msgs = (self.buffer + message).split('\n')
            self.buffer = msgs.pop(-1)
            for m in msgs:
                self.log_orig(m, echo=True)
        finally:
            self.__thread_local_ctx.write_count -= 1
7244
private void socketWrite(byte b[], int off, int len) throws IOException {

        if (len <= 0 || off < 0 || off + len > b.length) {
            if (len == 0) {
                return;
            }
            throw new ArrayIndexOutOfBoundsException();
        }

        Object traceContext = IoTrace.socketWriteBegin();
        int bytesWritten = 0;
        FileDescriptor fd = impl.acquireFD();
        try {
            BlockGuard.getThreadPolicy().onNetwork();
            socketWrite0(fd, b, off, len);
            bytesWritten = len;
        } catch (SocketException se) {
            if (se instanceof sun.net.ConnectionResetException) {
                impl.setConnectionResetPending();
                se = new SocketException("Connection reset");
            }
            if (impl.isClosedOrPending()) {
                throw new SocketException("Socket closed");
            } else {
                throw se;
            }
        } finally {
            IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
        }
    }
1059205
def _write(self, data):
        
        total_sent = 0
        length = len(data)
        while total_sent < length:
            try:
                sent = self.socket.send(data[total_sent:])
            except socket.error as (err, msg):
                self.connected = False
                raise ScratchError("[Errno %d] %s" % (err, msg))
            if sent == 0:
                self.connected = False
                raise ScratchConnectionError("Connection broken")
            total_sent += sent
1020524
def write(self, msg):
        
        self._current_stream.write(msg)
        for log in self._logs.values():
            log.append(msg)
1098235
def write(self, out):
        """"""
        out.write_string(self.address, len(self.address))
570894
def _output(self, s):
    """"""

    if s.lower().startswith(b'host: '):
        self._buffer.insert(1, s)
    else:
        self._buffer.append(s)
1254469
def write(message, priority=Priority.INFO):
    

    priority = int(Priority(int(priority)))

    send(priority=priority, message=message)
563411
def _emit_message(cls, message):
        """"""
        sys.stdout.write(message)
        sys.stdout.flush()
930303
def write(data, timeout = @timeout)
      full_size = data.bytesize

      while data.bytesize > 0
        written = socket.write_nonblock(data, exception: false)

        if written == :wait_writable
          socket.wait_writable(timeout) or fail_with_timeout!
        else
          data = data.byteslice(written..-1)
        end
      end

      full_size
    end
1066909
def write(self, s):
        
        try:
            self._write_lock.acquire()
            self.handle.sendall(s)
        except socket.timeout:
            self._connect()
        except socket.error:
            raise IOError
        finally:
            self._write_lock.release()
1345127
def write(self, buf):
        """"""
        return self.transport_sock.sendto(
            buf,
            (self.transport_host, self.transport_port)
        )
33637
def write_message(self, message, timeout):
    
    with self._writer_lock:
      self._transport.write(message.header, timeout.remaining_ms)

      # Use any remaining time to send the data.  Note that if we get this far,
      # we always at least try to send the data (with a minimum of 10ms timeout)
      # because we don't want the remote end to get out of sync because we sent
      # a header but no data.
      if timeout.has_expired():
        _LOG.warning('Timed out between AdbMessage header and data, sending '
                     'data anyway with 10ms timeout')
        timeout = timeouts.PolledTimeout.from_millis(10)
      self._transport.write(message.data, timeout.remaining_ms)
1275426
def _write(self, request):
    """"""
    with sw("serialize_request"):
      request_str = request.SerializeToString()
    with sw("write_request"):
      with catch_websocket_connection_errors():
        self._sock.send(request_str)