Code Duplication    Length = 12-12 lines in 2 locations

PHPDaemon/BoundSocket/TCP.php 1 location

@@ 70-81 (lines=12) @@
67
            Daemon::$process->log(get_class($this->pool) . ': Couldn\'t create TCP-socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
68
            return false;
69
        }
70
        if ($this->reuse) {
71
            if (!socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1)) {
72
                $errno = socket_last_error();
73
                Daemon::$process->log(get_class($this->pool) . ': Couldn\'t set option REUSEADDR to socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
74
                return false;
75
            }
76
            if (defined('SO_REUSEPORT') && !@socket_set_option($sock, SOL_SOCKET, SO_REUSEPORT, 1)) {
77
                $errno = socket_last_error();
78
                Daemon::$process->log(get_class($this->pool) . ': Couldn\'t set option REUSEPORT to socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
79
                return false;
80
            }
81
        }
82
        if (!@socket_bind($sock, $this->host, $port)) {
83
            $errno = socket_last_error();
84
            Daemon::$process->log(get_class($this->pool) . ': Couldn\'t bind TCP-socket \'' . $this->host . ':' . $port . '\' (' . $errno . ' - ' . socket_strerror($errno) . ').');

PHPDaemon/BoundSocket/UDP.php 1 location

@@ 116-127 (lines=12) @@
113
                Daemon::log(get_class($this) . ' (' . get_class($this->pool) . '): no port defined for \'' . $this->uri['uri'] . '\'');
114
            }
115
        }
116
        if ($this->reuse) {
117
            if (!socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1)) {
118
                $errno = socket_last_error();
119
                Daemon::$process->log(get_class($this) . ': Couldn\'t set option REUSEADDR to socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
120
                return false;
121
            }
122
            if (defined('SO_REUSEPORT') && !@socket_set_option($sock, SOL_SOCKET, SO_REUSEPORT, 1)) {
123
                $errno = socket_last_error();
124
                Daemon::$process->log(get_class($this) . ': Couldn\'t set option REUSEPORT to socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
125
                return false;
126
            }
127
        }
128
        if (!@socket_bind($sock, $this->host, $this->port)) {
129
            $errno = socket_last_error();
130
            $addr = $this->host . ':' . $this->port;