53 if ( preg_match(
'!^udp:(?://)?\[([0-9a-fA-F:]+)\]:(\d+)(?:/(.*))?$!', $info, $m ) ) {
56 $port = intval( $m[2] );
59 } elseif ( preg_match(
'!^udp:(?://)?([a-zA-Z0-9.-]+):(\d+)(?:/(.*))?$!', $info, $m ) ) {
64 $port = intval( $m[2] );
68 throw new InvalidArgumentException( __METHOD__ .
': Invalid UDP specification' );
77 public function emit( $text ) {
79 if ( $this->prefix !==
false ) {
80 $text = preg_replace(
'/^/m', $this->prefix .
' ', $text );
83 if ( strlen( $text ) > 65506 ) {
84 $text = substr( $text, 0, 65506 );
87 if ( substr( $text, -1 ) !=
"\n" ) {
90 } elseif ( strlen( $text ) > 65507 ) {
91 $text = substr( $text, 0, 65507 );
94 $sock = socket_create( $this->domain, SOCK_DGRAM, SOL_UDP );
99 socket_sendto( $sock, $text, strlen( $text ), 0, $this->host, $this->
port );
100 socket_close( $sock );