Sends data on the connection.

@param string $send_buffer
@param bool   $raw
@return void|boolean
483192
public function send($send_buffer, $raw = false)
    {
        if (false === $raw && $this->protocol) {
            $parser      = $this->protocol;
            $send_buffer = $parser::encode($send_buffer, $this);
            if ($send_buffer === '') {
                return null;
            }
        }
        return strlen($send_buffer) === stream_socket_sendto($this->_socket, $send_buffer, 0, $this->_remoteAddress);
    }
76175
def send_raw(self, string):
        
        log.debug('RAW: {}'.format(string))
        if self.transport is None:
            raise ServerNotConnectedError("Not connected.")

        self.transport.write(self._prep_message(string))
952443
def socket_send(self):
        
        if len(self.send_buffer):
            try:
                sent = self.sock.send(self.send_buffer)
            except socket.error, err:
                print("!! SEND error '%d:%s' from %s" % (err[0], err[1],
                    self.addrport()))
                self.active = False
                return
            self.bytes_sent += sent
            self.send_buffer = self.send_buffer[sent:]
        else:
            self.send_pending = False
527393
def send(self, url, data, headers):
        
        eventlet.spawn(self._send_payload, (url, data, headers))
447505
public static function sendData($address, $buffer)
    {
        $socket = stream_socket_client($address);
        if(!$socket)
        {
            return false;
        }
        return stream_socket_sendto($socket, $buffer) == strlen($buffer);
    }
1216802
public boolean send()
	{
		assert sentRequests == null;
		sentRequests = new ArrayList<RequestCallInfo>();

		// add prepended requests,
		addPrependedRequests( sentRequests );

		// add requests to send
		while( !requestsToSend.isEmpty() )
			sentRequests.add( requestsToSend.remove( 0 ) );

		// add appended requests
		addAppendedRequests( sentRequests );

		// prepare payload
		JSONArray payload = createPayload();

		RequestBuilder builderPost = buildMultipart( "payload", payload.toString() );

		nbSentBytes += builderPost.getRequestData().length();

		try
		{
			sentRequest = builderPost.send();
		}
		catch( RequestException e )
		{
			callback.error( RPCErrorCodes.ERROR_REQUEST_SEND, e, this );
			return false;
		}

		callback.sent( this );

		return true;
	}
112934
public function close($data = null, $raw = false)
    {
        if ($this->_status === self::STATUS_CLOSING || $this->_status === self::STATUS_CLOSED) {
            return;
        } else {
            if ($data !== null) {
                $this->send($data, $raw);
            }
            $this->_status = self::STATUS_CLOSING;
        }
        if ($this->_sendBuffer === '') {
            $this->destroy();
        }
    }
1203270
private function send_request() {
        // check if stream is declared to be open
        // only logical check we are not sure if socket is really still open ...
        if ($this->_connection_closed) {
            // reopen it
            // be sure to close the open socket.
            $this->close();
            $this->reopen();
        }

        // convert array to string
        $buffer = implode("\r\n", $this->_req);
        $buffer .= "\r\n\r\n";
        $this->_error_log($buffer);
        fputs($this->sock, $buffer);
    }
508048
def send(self, data):
        
        assert isinstance(data, text_type)

        # When data is send back to the client, we should replace the line
        # endings. (We didn't allocate a real pseudo terminal, and the telnet
        # connection is raw, so we are responsible for inserting \r.)
        self.stdout.write(data.replace('\n', '\r\n'))
        self.stdout.flush()
518958
private function connected() : void
    {
        $this->connected = true;
        while ($this->buffer) {
            $this->client->send(array_shift($this->buffer));
        }
    }
979766
public static function sendPost($_url, $_data, $_headers = [],
                                    $_return_header = true)
    {
        return self::sendCurl($_url,
                array(
                CURLOPT_SSL_VERIFYHOST => false,
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_FOLLOWLOCATION => 0,
                CURLOPT_POST => 1,
                CURLOPT_POSTFIELDS => $_data,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_HTTPHEADER => $_headers,
                CURLOPT_HEADER => $_return_header
        ));
    }
404849
def send_raw_packet(self, packet: str):
        """"""
        data = packet + '\r\n'
        log.debug('writing data: %s', repr(data))
        self.transport.write(data.encode())
326975
async def send_rpc(self, conn_id, address, rpc_id, payload, timeout):
        

        self._ensure_connection(conn_id, True)
        connection_string = self._get_property(conn_id, "connection_string")

        msg = dict(address=address, rpc_id=rpc_id, payload=base64.b64encode(payload),
                   timeout=timeout, connection_string=connection_string)

        response = await self._send_command(OPERATIONS.SEND_RPC, msg, COMMANDS.SendRPCResponse,
                                            timeout=timeout)

        return unpack_rpc_response(response.get('status'), response.get('payload'),
                                   rpc_id=rpc_id, address=address)
1064194
public synchronized Boolean sendRaw(byte... rawBytes) {
        if (!start()) {
            log.error("Firmata library is not connected / started! Cannot send bytes {}",
                    FirmataHelper.bytesToHexString(rawBytes));
            return false;
        }

        try {
            serialPort.getOutputStream().write(rawBytes);
            return true;
        } catch (IOException e) {
            log.error("Unable to transmit raw bytes through serial port. Bytes: {}",
                    FirmataHelper.bytesToHexString(rawBytes));
            stop();
        }

        return false;
    }
1267099
public function send($message, $raw=false)
    {
        if(!$raw && $this->parser){
            $message = call_user_func([$this->parser, 'encode'], $message, $this);
        }
        
        if($message === false || $message === null) {
            return false;
        }
        
        $message = (string)$message;
        
        if($this->isUDP() ) {
            return stream_socket_sendto($this->socket, $message);
        }
        
        if ($this->bufferIsFull()) {
            if($this->_pipe) {
                $this->_pipe->pauseRecv();
            }
            $this->trigger(Server::ON_BUFFER_FULL, new IOEvent());
            return false;
        }
        
        if(!$this->isConnnected()) {
            $this->sendBuffer .= $message;
            return ;
        }
        
        if($this->sendBuffer === ''){
            $len = fwrite($this->socket, $message);
            if ($len === strlen($message)) {
                return true;
            }else if($len >0) {
                $this->sendBuffer = substr($message, $len);
                Yii::$app->eventLooper->add($this->socket, EventLooper::EV_WRITE, [$this, 'baseWrite']);
            } else {
                $error = error_get_last();
                
                $event = new ErrorEvent([
                    'code' => $error['type'],
                    'errstr' => $error['message'],
                ]);
                
                $this->trigger(Server::ON_ERROR, $event);
                
                if(!is_resource($this->socket) || feof($this->socket)){
                    
                    $this->status = static::STATUS_CLOSED;
                    
                    $this->removeEventLooper();
                    
                    $event = new CloseEvent([
                        'by' => CloseEvent::BY_PEER,
                    ]);
                    $this->trigger(Server::ON_CLOSE, $event);
                    $this->destroy();
                    return false;
                }
            }
            
            return $len;
        }else{
            if ($this->bufferIsFull()) {
                $this->trigger(Server::ON_BUFFER_FULL, new IOEvent());
                return false;
            }
            
            $this->sendBuffer .= $message;
            
            return strlen($message);
        }
    }
796658
def sendData(self, data):
        """"""
        # Not set up yet
        if self.client_log is None:
            self.client_log_buffer.append(data)
        else:
            self.client_log.write(data)
        self.transport.write(data)
799141
def _send_raw(self, command):
        
        try:
            self._socket.send(bytearray(command))
            self._sn = (self._sn + 1) % 256
            return True
        except (socket.error, socket.timeout):
            # We can get a socket.error or timeout exception if the bridge is disconnected,
            # but we are still sending data. In that case, return False to indicate that data is not sent.
            return False