Send the response in blocks of the given len using the
        passed method dependending on the socket type.
334728
def write_to_stream(stream, response, block_len=1024):
        
        try:
            i_start = 0
            i_end = block_len
            while True:
                if i_end > len(response):
                    stream(response[i_start:])
                    break
                stream(response[i_start:i_end])
                i_start = i_end
                i_end += block_len
        except (socket.timeout, socket.error) as exception:
            logger.debug('Error sending response to the client: %s', exception)
992023
def mock_server_receive(sock, length):
    """"""
    msg = b''
    while length:
        chunk = sock.recv(length)
        if chunk == b'':
            raise socket.error(errno.ECONNRESET, 'closed')

        length -= len(chunk)
        msg += chunk

    return msg
1182882
def respond(self, packet, peer, flags=0):
        
        self.sock.sendto(packet, flags, peer)
1066321
def send(self, data):
        """"""
        bytes_sent = self._sock.send(extract_bytes(data))
        self.bytes_written += bytes_sent
        return bytes_sent
575510
def send_message(
        self, request: str, response_expected: bool, **kwargs: Any
    ) -> Response:
        
        self.socket.send_string(request)
        return Response(self.socket.recv().decode())
949213
def respond(self):
        """"""
        mrbs = self.server.max_request_body_size
        if self.chunked_read:
            self.rfile = ChunkedRFile(self.conn.rfile, mrbs)
        else:
            cl = int(self.inheaders.get("Content-Length", 0))
            if mrbs and mrbs < cl:
                if not self.sent_headers:
                    self.simple_response("413 Request Entity Too Large",
                        "The entity sent with the request exceeds the maximum "
                        "allowed bytes.")
                return
            self.rfile = KnownLengthRFile(self.conn.rfile, cl)
        
        self.server.gateway(self).respond()
        
        if (self.ready and not self.sent_headers):
            self.sent_headers = True
            self.send_headers()
        if self.chunked_write:
            self.conn.wfile.sendall("0\r\n\r\n")
1035134
def send(self, packet_buffer):
        
        if self._handle is None:
            raise self.DeviceIsNotOpen()
        buffer_length = len(packet_buffer)
        buf_send = ctypes.cast(ctypes.create_string_buffer(packet_buffer, buffer_length),
                               ctypes.POINTER(ctypes.c_ubyte))
        wtypes.pcap_sendpacket(self._handle, buf_send, buffer_length)
114219
void send(byte streamCode, byte[] b, int offset, int len) throws IOException {
    synchronized (writeLock) {
      out.writeInt(len);
      out.writeByte(streamCode);
      out.write(b, offset, len);
    }
    out.flush();
  }
1263183
def send(self, data):
        
        try:
            self.socket.sendto(data.encode('utf8') + b'\n', (self.host, self.port))
        except (socket.error, RuntimeError):
            # Socket errors should fail silently so they don't affect anything else
            pass
246560
def RPC(self, url, opname, obj, replytype=None, **kw):
        '''
        '''
        self.Send(url, opname, obj, **kw)
        return self.Receive(replytype, **kw)
137985
def send_response(response)
      case response
      when Gopher::Response then send_response(response.body)
      when String then send_data(response + end_of_transmission)
      when StringIO then send_data(response.read + end_of_transmission)
      when File
        while chunk = response.read(8192) do
          send_data(chunk)
        end
        response.close
      end
    end
1339934
def sendACK(self, blocknumber=None):
        """"""
        log.debug("In sendACK, passed blocknumber is %s", blocknumber)
        if blocknumber is None:
            blocknumber = self.context.next_block
        log.info("Sending ack to block %d" % blocknumber)
        ackpkt = TftpPacketACK()
        ackpkt.blocknumber = blocknumber
        self.context.sock.sendto(ackpkt.encode().buffer,
                                 (self.context.host,
                                  self.context.tidport))
        self.context.last_pkt = ackpkt
935167
def send(self, data):
        """"""
        # send message
        _LOGGER.debug("send: " + data)
        self.socket.send(data.encode('ascii'))
        # sleep needed to prevent flooding the GC100 with sends
        sleep(.01)
1015530
private ByteBuffer recv(int attempt)
          throws IOException, SocketException, SocketTimeoutException {
    int timeout = UDP_BASE_TIMEOUT_SECONDS * (int) Math.pow(2, attempt);
    logger.trace("Setting receive timeout to {}s for attempt {}...",
            timeout, attempt);
    this.socket.setSoTimeout(timeout * 1000);

    try {
      DatagramPacket p = new DatagramPacket(
              new byte[UDP_PACKET_LENGTH],
              UDP_PACKET_LENGTH);
      this.socket.receive(p);
      return ByteBuffer.wrap(p.getData(), 0, p.getLength());
    } catch (SocketTimeoutException ste) {
      throw ste;
    }
  }
740127
def send_buffer(self):
        
        buf = self._send_buf
        sock = self.connection._sock
        try:
            timeout = sock.gettimeout()
            sock.setblocking(False)
            try:
                for idx, item in enumerate(buf):
                    sent = 0
                    while 1:
                        try:
                            sent = sock.send(item)
                        except IOError as e:
                            if e.errno == errno.EAGAIN:
                                continue
                            elif e.errno == errno.EWOULDBLOCK:
                                break
                            raise
                        self.sent_something = True
                        break
                    if sent < len(item):
                        buf[:idx + 1] = [item[sent:]]
                        break
                else:
                    del buf[:]
            finally:
                sock.settimeout(timeout)
        except IOError as e:
            self.connection.disconnect()
            if isinstance(e, socket.timeout):
                raise TimeoutError('Timeout writing to socket (host %s)'
                                   % self.host_id)
            raise ConnectionError('Error while writing to socket (host %s): %s'
                                  % (self.host_id, e))
285232
def _send(self, messagetype, packet):
		""""""

		packet.validate()
		data = packet.encode()

		logger.debug('To : %s:%s <%s>\n%s', self.hostname, self.port, packet.__class__, data)

		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.settimeout(self.socketTimeout)
		try:
			s.connect((self.hostname, self.port))
			s.send(data)
			recv_data = s.recv(1024)
			while not recv_data.endswith(gntp.shim.b("\r\n\r\n")):
				recv_data += s.recv(1024)
		except socket.error:
			# Python2.5 and Python3 compatibile exception
			exc = sys.exc_info()[1]
			raise errors.NetworkError(exc)

		response = gntp.core.parse_gntp(recv_data)
		s.close()

		logger.debug('From : %s:%s <%s>\n%s', self.hostname, self.port, response.__class__, response)

		if type(response) == gntp.core.GNTPOK:
			return True
		logger.error('Invalid response: %s', response.error())
		return response.error()
865301
def send(x, inter=0, loop=0, count=None, verbose=None, realtime=None, *args, **kargs):
    """"""
    __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)