PHPDaemon\Network\Server::bindSockets PHP Method

bindSockets() public method

Bind given sockets
public bindSockets ( mixed $addrs = [], integer $max ) : integer
$addrs mixed Addresses to bind
$max integer Maximum
return integer Number of bound
    public function bindSockets($addrs = [], $max = 0)
    {
        if (is_string($addrs)) {
            $addrs = array_map('trim', explode(',', $addrs));
        }
        $n = 0;
        foreach ($addrs as $addr) {
            if ($this->bindSocket($addr)) {
                ++$n;
            }
            if ($max > 0 && $n >= $max) {
                return $n;
            }
        }
        return $n;
    }