Code Duplication    Length = 5-7 lines in 3 locations

PHPDaemon/BoundSocket/TCP.php 2 locations

@@ 82-86 (lines=5) @@
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) . ').');
85
            return false;
86
        }
87
        socket_getsockname($sock, $this->host, $this->port);
88
        socket_set_nonblock($sock);
89
        if (!$this->listenerMode) {
@@ 89-95 (lines=7) @@
86
        }
87
        socket_getsockname($sock, $this->host, $this->port);
88
        socket_set_nonblock($sock);
89
        if (!$this->listenerMode) {
90
            if (!socket_listen($sock, SOMAXCONN)) {
91
                $errno = socket_last_error();
92
                Daemon::$process->log(get_class($this->pool) . ': Couldn\'t listen TCP-socket \'' . $this->host . ':' . $port . '\' (' . $errno . ' - ' . socket_strerror($errno) . ')');
93
                return false;
94
            }
95
        }
96
        $this->setFd($sock);
97
        return true;
98
    }

PHPDaemon/BoundSocket/UDP.php 1 location

@@ 128-133 (lines=6) @@
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;
131
            Daemon::$process->log(get_class($this) . ': Couldn\'t bind UDP-socket \'' . $addr . '\' (' . $errno . ' - ' . socket_strerror($errno) . ').');
132
            return false;
133
        }
134
        socket_getsockname($sock, $this->host, $this->port);
135
        $addr = $this->host . ':' . $this->port;
136
        socket_set_nonblock($sock);