library/Wcx/Syslog/Transport/Tcp.php
public function send(MessageInterface $message, $target)
    {
        //Add EOL to message so the receiver knows it has ended
        $msg = $message->getMessageString() . "\n";

        if (strpos($target, ':')) {
            list($host, $port) = explode(':', $target);
        } else {
            $host = $target;
            $port = self::DEFAULT_TCP_PORT;
        }

        $sock = fsockopen($host, $port, $errorCode, $errorMsg, $this->timeout);
        if ($sock === false) {
            throw new \RuntimeException("Error connecting to {$server}: [{$errorCode}] {$errorMsg}");
        }

        $written = fwrite($sock, $msg);
        fclose($sock);

        if ($written != strlen($msg)) {
            throw new \RuntimeException("Error sending message to {$server} not all bytes sent.");
        }

        return $this;
    }
public function send(MessageInterface $message, $target)
    {
        //Add EOL to message so the receiver knows it has ended
        $msg = $message->getMessageString() . "\n";

        if (strpos($target, ':')) {
            list($host, $port) = explode(':', $target);
        } else {
            $host = $target;
            $port = self::DEFAULT_TCP_PORT;
        }

        $sock = fsockopen($host, $port, $errorCode, $errorMsg, $this->timeout);
        if ($sock === false) {
            throw new \RuntimeException("Error connecting to {$server}: [{$errorCode}] {$errorMsg}");
        }

        $written = fwrite($sock, $msg);
        fclose($sock);

        if ($written != strlen($msg)) {
            throw new \RuntimeException("Error sending message to {$server} not all bytes sent.");
        }

        return $this;
    }
public function send ( MessageInterface $ message , $ target ) { //Add EOL to message so the receiver knows it has ended $ msg = $ message -> getMessageString ( ) . "\n" ; if ( strpos ( $ target , ':' ) ) { list ( $ host , $ port ) = explode ( ':' , $ target ) ; } else { $ host = $ target ; $ port = self :: DEFAULT_TCP_PORT ; } $ sock = fsockopen ( $ host , $ port , $ errorCode , $ errorMsg , $ this -> timeout ) ; if ( $ sock === false ) { throw new \ RuntimeException ( "Error connecting to {$server}: [{$errorCode}] {$errorMsg}" ) ; } $ written = fwrite ( $ sock , $ msg ) ; fclose ( $ sock ) ; if ( $ written != strlen ( $ msg ) ) { throw new \ RuntimeException ( "Error sending message to {$server} not all bytes sent." ) ; } return $ this ; }
Send the syslog to target host using the TCP protocol.Automatically adds a \n character to end
of the message string
@param  MessageInterface $message
@param  string           $target  Host:port, if port not specified uses default 514
@return void
@throws \RuntimeException If there's an error creating the socket
Send the syslog to target host using the TCP protocol . Automatically adds a \ n character to end of the message string