Sends a packet to an SSH server

@param string $data
@access private
760570
function _send($data)
    {
        switch ($this->mode) {
            case self::MODE_SSH2:
                $this->ssh->_send_channel_packet(SSH2::CHANNEL_EXEC, $data);
                break;
            case self::MODE_SSH1:
                $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data);
                $this->ssh->_send_binary_packet($data);
        }
    }
165065
public function send(array $data, $sampleRate = 1)
    {
        if (!$this->enable) {
            return;
        }

        // sampling
        $sampledData = array();
        if ($sampleRate < 1) {
            foreach ($data as $stat => $value) {
                if ((mt_rand() / mt_getrandmax()) <= $sampleRate) {
                    $sampledData[$stat] = "$value|@$sampleRate";
                }
            }
        } else {
            $sampledData = $data;
        }
        if (empty($sampledData)) {
            return;
        }

        $fp = fsockopen('udp://' . $this->host, $this->port, $errno, $errstr);
        if (!$fp) {
            return;
        }
        foreach ($sampledData as $stat => $value) {
            fwrite($fp, $stat . ':' . $value);
        }
        fclose($fp);
    }
294377
public function write($data)
    {
        if ($this->dgram) {
            return $this->parentSocket->sendTo($data, $this->finished ? MSG_EOF : 0, $this->host, $this->port);
        }
        return parent::write($data);
    }
1291938
public function sendData($data)
    {
        // Issue #20 no data values should be null.

        array_walk($data, function (&$value) {
            if (! isset($value)) {
                $value = '';
            }
        });

        $httpResponse = $this
            ->httpClient
            ->request(
                'POST',
                $this->getEndpoint(),
                [
                    'Content-Type' => 'application/x-www-form-urlencoded',
                ],
                http_build_query($data)
            );

        // We might want to check $httpResponse->getStatusCode()

        $responseData = static::parseBodyData($httpResponse);

        return $this->createResponse($responseData);
    }
908975
protected function send($data, $sampleRate=1) {
        $sampledData = array();
        if ($sampleRate < 1) {
            foreach ($data as $stat => $value) {
                if ((mt_rand() / mt_getrandmax()) <= $sampleRate) {
                    $sampledData[$stat] = "$value|@$sampleRate";
                }
            }
        } else {
            $sampledData = $data;
        }
        if (empty($sampledData)) { return; }
        try
        {
            if (!empty($this->host)) // if host is configured, send..
            {
                $fp = fsockopen("udp://{$this->host}", $this->port);
                if (! $fp) { return; }
                // make this a non blocking stream
                stream_set_blocking($fp, false);
                foreach ($sampledData as $stat => $value)
                {
                    if (is_array($value))
                    {
                        foreach ($value as $v)
                        {
                            fwrite($fp, "$stat:$v");
                        }
                    }
                    else
                    {
                        fwrite($fp, "$stat:$value");
                    }
                }
                fclose($fp);
            }
        }
        catch (\Exception $e)
        {
        }
    }
636480
public function client_send($data)
    {
        if ($this->do_debug >= 1) {
            $this->edebug("CLIENT -> SERVER: $data");
        }
        return fwrite($this->smtp_conn, $data);
    }
619671
public function sendDataAsJson($data) {
    $this->disableView();
    $this->setContentType('application/json', 'UTF-8');
    if (is_object($data)) {
      if (method_exists($data,'toArray'))
        $data = $data->toArray();
    }
    if (empty($data))
      $data = new \stdClass();
    
    $this->setJsonContent($data);
    $this->send();
  }
1052858
public function sendChunk($data, $lastChunk = false)
    {
        $this->chunked = true;

        if ($lastChunk) {
            $this->response->end($data);
        } elseif (strlen($data) > 0) {
            $this->response->write($data);
        }
    }
568151
public function sendRequest($data, $cookies = null)
    {
        // build cookie string
        $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));

        // build payload
        $this->buildPayload($data, $cookie_str);

        if ($this->io_method() == 'socket') {
            // send payload
            if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
                $this->setError('couldn\'t write message data to socket');
                $this->debug('couldn\'t write message data to socket');
                return false;
            }
            $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
            return true;
        } elseif ($this->io_method() == 'curl') {
            // set payload
            // cURL does say this should only be the verb, and in fact it
            // turns out that the URI and HTTP version are appended to this, which
            // some servers refuse to work with (so we no longer use this method!)
            //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
            $curl_headers = array();
            foreach ($this->outgoing_headers as $k => $v) {
                if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
                    $this->debug("Skip cURL header $k: $v");
                } else {
                    $curl_headers[] = "$k: $v";
                }
            }
            if ($cookie_str != '') {
                $curl_headers[] = 'Cookie: ' . $cookie_str;
            }
            $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
            $this->debug('set cURL HTTP headers');
            if ($this->request_method == "POST") {
                $this->setCurlOption(CURLOPT_POST, 1);
                $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
                $this->debug('set cURL POST data');
            } else {
            }
            // insert custom user-set cURL options
            foreach ($this->ch_options as $key => $val) {
                $this->setCurlOption($key, $val);
            }

            $this->debug('set cURL payload');
            return true;
        }
    }
23643
function send($data, $length = null) {
        if (!isset($this->pipes[0]))
            return 0;
        if (!isset($length))
            $length = strlen($data);
        return intval(fwrite($this->pipes[0], $data, $length));
    }
532611
protected function doRequest($data)
    {
        $this->send(self::MAGIC_HEADER.pack('N', strlen($data)));
        $this->send($data);

        $data = $this->receive();

        $this->checkReceivedDataMagic($data);

        $status = unpack('Nstatus', substr($data, 4, 4))['status'];
        $data = substr($data, 12);

        if ($status != 200) {
            throw new TransportException($data ?: 'Http request failed, status: '.$status,
                TransportException::REMOTE);
        }

        return $data;
    }
1007496
public function sendData($data)
    {
        $response = $this->braintree->transaction()->sale($data);

        return $this->createResponse($response);
    }
654751
public function sendData($data)
    {
        $response = $this->braintree->paymentMethod()->update($data['token'], $data);

        return $this->createResponse($response);
    }
422230
public static function send ( $response ) {
      $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ?
          $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
      $code = $response->code();
      $status = ResponseCode::find( $code );
      $body = $response->body();
      header( "$protocol $code $status", true, intval( $code ) );
      foreach ( $response->headers() as $a => $v )
        header( "$a: $v" );
      if ( is_string( $body ) && strlen( $body ) > 0 )
        echo $body;
    }
1276090
function sendAll($client_id = null, $data)
    {
        foreach ($this->client_sock as $k => $sock)
        {
            if ($client_id and $k == $client_id) continue;
            $this->sendData($sock, $data);
        }
    }
1325046
public function write($data)
    {

        try {
            // No socket for this server, make one
            if (is_null($this->socket)) {
                $this->create();
            }

            // Send the packet
            return fwrite($this->socket, $data);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
204167
function send($data)
    {
        $len = strlen($data);
        $n = socket_sendto($this->sock, $data, $len, 0, $this->host, $this->port);

        if ($n === false or $n < $len) {
            $this->set_error();
            return false;
        } else {
            return $n;
        }
    }