ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Handler\SyslogUdp\UdpSocket Class Reference
+ Collaboration diagram for Monolog\Handler\SyslogUdp\UdpSocket:

Public Member Functions

 __construct ($ip, $port=514)
 
 write ($line, $header="")
 
 close ()
 

Data Fields

const DATAGRAM_MAX_LENGTH = 65023
 

Protected Member Functions

 send ($chunk)
 
 assembleMessage ($line, $header)
 

Protected Attributes

 $ip
 
 $port
 
 $socket
 

Detailed Description

Definition at line 14 of file UdpSocket.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Handler\SyslogUdp\UdpSocket::__construct (   $ip,
  $port = 514 
)

Definition at line 22 of file UdpSocket.php.

References Monolog\Handler\SyslogUdp\UdpSocket\$ip, and Monolog\Handler\SyslogUdp\UdpSocket\$port.

23  {
24  $this->ip = $ip;
25  $this->port = $port;
26  $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
27  }

Member Function Documentation

◆ assembleMessage()

Monolog\Handler\SyslogUdp\UdpSocket::assembleMessage (   $line,
  $header 
)
protected

Definition at line 50 of file UdpSocket.php.

References $header.

Referenced by Monolog\Handler\SyslogUdp\UdpSocket\write().

51  {
52  $chunkSize = self::DATAGRAM_MAX_LENGTH - strlen($header);
53 
54  return $header . substr($line, 0, $chunkSize);
55  }
+ Here is the caller graph for this function:

◆ close()

Monolog\Handler\SyslogUdp\UdpSocket::close ( )

Definition at line 34 of file UdpSocket.php.

35  {
36  if (is_resource($this->socket)) {
37  socket_close($this->socket);
38  $this->socket = null;
39  }
40  }

◆ send()

Monolog\Handler\SyslogUdp\UdpSocket::send (   $chunk)
protected

Definition at line 42 of file UdpSocket.php.

Referenced by Monolog\Handler\SyslogUdp\UdpSocket\write().

43  {
44  if (!is_resource($this->socket)) {
45  throw new \LogicException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore');
46  }
47  socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
48  }
+ Here is the caller graph for this function:

◆ write()

Monolog\Handler\SyslogUdp\UdpSocket::write (   $line,
  $header = "" 
)

Definition at line 29 of file UdpSocket.php.

References $header, Monolog\Handler\SyslogUdp\UdpSocket\assembleMessage(), and Monolog\Handler\SyslogUdp\UdpSocket\send().

30  {
31  $this->send($this->assembleMessage($line, $header));
32  }
+ Here is the call graph for this function:

Field Documentation

◆ $ip

Monolog\Handler\SyslogUdp\UdpSocket::$ip
protected

Definition at line 18 of file UdpSocket.php.

Referenced by Monolog\Handler\SyslogUdp\UdpSocket\__construct().

◆ $port

Monolog\Handler\SyslogUdp\UdpSocket::$port
protected

Definition at line 19 of file UdpSocket.php.

Referenced by Monolog\Handler\SyslogUdp\UdpSocket\__construct().

◆ $socket

Monolog\Handler\SyslogUdp\UdpSocket::$socket
protected

Definition at line 20 of file UdpSocket.php.

◆ DATAGRAM_MAX_LENGTH

const Monolog\Handler\SyslogUdp\UdpSocket::DATAGRAM_MAX_LENGTH = 65023

Definition at line 16 of file UdpSocket.php.


The documentation for this class was generated from the following file: