26 $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
36 if (is_resource($this->socket)) {
37 socket_close($this->socket);
42 protected function send($chunk)
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');
47 socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
52 $chunkSize = self::DATAGRAM_MAX_LENGTH - strlen(
$header);
54 return $header . substr($line, 0, $chunkSize);
assembleMessage($line, $header)
__construct($ip, $port=514)
const DATAGRAM_MAX_LENGTH