Send the message over UDP

@param $message
354200
protected function flush($message)
    {
        $this->socket->create(AF_INET, SOCK_DGRAM, SOL_UDP);
        $this->socket->setNonBlocking();
        $this->socket->sendMessage($message, $this->server, $this->port);
        $this->socket->close();
    }
267823
public function send(OutgoingMessage $message)
    {
        $messageToSend = $message->serialize();
        $length = strlen($messageToSend);
        $this->logger->debug(
            '------ Sending: ------ ' . "\n" . $messageToSend . '----------'
        );
        $this->lastActionId = $message->getActionId();
        if (@fwrite($this->socket, $messageToSend) < $length) {
            throw new ClientException('Could not send message');
        }
        $read = 0;
        while ($read <= $this->rTimeout) {
            $this->process();
            $response = $this->getRelated($message);
            if ($response != false) {
                $this->lastActionId = false;
                return $response;
            }
            usleep(1000); // 1ms delay
            if ($this->rTimeout > 0) {
                $read++;
            }
        }
        throw new ClientException('Read timeout');
    }
185452
private function SendMessage($message)
    {
        $this->signal_data->message = $message;
        
        $this->Send(
            \Peg\Lib\Signals\Type\Definitions::IMPORT_MESSAGE,
            $this->signal_data
        );
    }
55768
public function send($message)
    {
        try {
            $code = 200;
            $this->sendCommand($this->getTargetServiceName(), $message, false);
            $message = 'Command has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
303140
public function send(Message $message)
    {
        $protocolClass = '\O2System\Email\Protocols\\' . ucfirst($this->config->offsetGet('protocol')) . 'Protocol';

        if (class_exists($protocolClass)) {
            $protocol = new $protocolClass($this);

            if ($protocol instanceof AbstractProtocol) {
                return $protocol->send($message);
            }
        }

        return false;
    }
1160726
public function send($recipient, $message)
    {
        try {
            return $this->gateway->sendMessage($recipient, $message);
        } catch (AfricasTalkingGatewayException $e) {
            echo "Encountered an error while sending: " . $e->getMessage();
        }
    }
383461
public function send(OutgoingMessage $message)
    {
        foreach ($message->getTo() as $number) {
            $this->logger->notice("Sending SMS message to: $number");
        }
    }
429613
public function send(Message $message)
    {
        $this->connection();

        $error = true;

        // SMTP command
        if ($this->username !== null) {
            $this->write('MAIL FROM: <' . $this->username . '>', 250);
        } else {
            if ($message->getFrom() !== null) {
                $this->write('MAIL FROM: <' . $message->getFrom() . '>', 250);
            }
        }

        foreach ($message->getTo() as $value) {
            if ($value[0] !== null) {
                $to = $value[0] . '<' . $value[1] . '>';
            } else {
                $to = '<' . $value[1] . '>';
            }

            $this->write('RCPT TO: ' . $to, 250);
        }

        $this->write('DATA', 354);
        $data = 'Subject: ' . $message->getSubject() . Message::END;
        $data .= $message->compileHeaders();
        $data .= 'Content-Type: ' . $message->getType() . '; charset=' . $message->getCharset() . Message::END;
        $data .= 'Content-Transfer-Encoding: 8bit' . Message::END;
        $data .= Message::END . $message->getMessage() . Message::END;
        $this->write($data);

        try {
            $this->write('.', 250);
        } catch (SmtpException $e) {
            echo $e->getMessage();
        }

        $status = $this->disconnect();

        if ($status == 221) {
            $error = false;
        }

        return (bool) $error;
    }
636846
public function error(string $message)
    {
        $this->relay->send(
            $message,
            Relay::PAYLOAD_CONTROL | Relay::PAYLOAD_RAW | Relay::PAYLOAD_ERROR
        );
    }
1335492
public function publish(Message $message)
    {
        // Check if required message parameters are set
        if (!$message->getShortMessage() || !$message->getHost()) {
            throw new \UnexpectedValueException(
              'Missing required data parameter: "version", "short_message" and "host" are required.'
            );
        }

        // Set Graylog protocol version
        $message->setVersion(self::GRAYLOG2_PROTOCOL_VERSION);

        // Encode the message as json string and compress it using gzip
        $preparedMessage = $this->getPreparedMessage($message);

        // Open a udp connection to graylog server
        $socket = $this->getSocketConnection();

        // Several udp writes are required to publish the message
        if ($this->isMessageSizeGreaterChunkSize($preparedMessage)) {
            // A unique id which consists of the microtime and a random value
            $messageId = $this->getMessageId();

            // Split the message into chunks
            $messageChunks = $this->getMessageChunks($preparedMessage);
            $messageChunksCount = count($messageChunks);

            // Send chunks to graylog server
            foreach (array_values($messageChunks) as $messageChunkIndex => $messageChunk) {
                $bytesWritten = $this->writeMessageChunkToSocket(
                  $socket,
                  $messageId,
                  $messageChunk,
                  $messageChunkIndex,
                  $messageChunksCount
                );

                if (false === $bytesWritten) {
                    // Abort due to write error
                    return false;
                }
            }
        } else {
            // A single write is enough to get the message published
            if (false === $this->writeMessageToSocket($socket, $preparedMessage)) {
                // Abort due to write error
                return false;
            }
        }

        // This increases stability a lot if messages are sent in a loop
        // A value of 20 means 0.02 ms
        usleep(20);

        // Message successful sent
        return true;
    }
1179368
public function sendText (Type\Text $message)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $message->getType(),
                    'Content' => $message->getContent(),
                ]
            )
        );
    }
373127
public function sendMessage(Message $message)
    {
        $payload = $this->preparePayload($message);

        $encoded = json_encode($payload, JSON_UNESCAPED_UNICODE);

        if ($encoded === false) {
            throw new RuntimeException(sprintf('JSON encoding error %s: %s', json_last_error(), json_last_error_msg()));
        }

        $this->guzzle->post($this->endpoint, ['body' => $encoded]);
    }
936751
public function send(Message $message) : void
    {
        $sender = $this->smtp['sender'];
        $recipients = is_array($sender['to']) ? $sender['to'] : [$sender['to']];

        $message->setFrom($sender['email'], $sender['name']);

        foreach ($recipients as $to)
        {
            $message->addTo($to);
        }

        $mailer = new \Nette\Mail\SmtpMailer($this->smtp['config']);
        $mailer->send($message);
    }
342709
public function send($message)
    {
        return $this->response->hydrate(
            $this->getPromise($message)
                ->receive()
                ->getBody()
        );
    }
831535
public function sendto(UdpMessageEvent $event, $message, $flag=0, $raw=false)
    {
        if(($event->sender instanceof Connection) && $event->sender->listener->parser){
            $message = call_user_func([$event->sender->listener->parser, 'encode'], $message, null);
        }
        
        stream_socket_sendto($event->socket, (string)$message, $flag, $event->peer);
    }
231385
protected function relayNotification($message)
    {
        $message = json_encode($message);

        foreach ($this->listenClients as $client) {
            if ($client->getState() < Net_Notifier_WebSocket_Connection::STATE_CLOSING) {

                $this->log(
                    sprintf(
                        ' ... relaying message "%s" to %s ... ',
                        $message,
                        $client->getIPAddress()
                    ),
                    Net_Notifier_Logger::VERBOSITY_CLIENT
                );

                $client->writeText($message);

                $this->log(
                    'done' . PHP_EOL,
                    Net_Notifier_Logger::VERBOSITY_CLIENT,
                    false
                );
            }
        }
    }
19073
public function sendDelayedMessage(string $message, int $delay = 0)
    {
        $delay = max(0, $delay);
        $delay = min(900, $delay);
        $this->sqsClient->sendMessage([
            'DelaySeconds' => $delay,
            'MessageBody'  => $message,
            'QueueUrl'     => $this->queueUrl,
        ]);
    }