public function connect(ZMQSocket $socket, $mode, $dsn)
    {
        if ($mode == self::MODE_CONSTRUCT) {
            return $this;
        }

        $func = null;
        if ($mode == self::MODE_BIND) {
            $func = 'bind';
        } elseif ($mode == self::MODE_CONNECT) {
            $func = 'connect';
        }

        if (is_string($dsn)) {
            $dsn = array($dsn);
        }

        if (!is_array($dsn)) {
            throw new \RuntimeException('DSN should be a string or an array.');
        }

        foreach ($dsn as $d) {
            if (!is_string($d)) {
                throw new \RuntimeException('Non-string in DSN array detected.');
            }
            $socket->$func($d);
        }
    }
public function connect(ZMQSocket $socket, $mode, $dsn)
    {
        if ($mode == self::MODE_CONSTRUCT) {
            return $this;
        }

        $func = null;
        if ($mode == self::MODE_BIND) {
            $func = 'bind';
        } elseif ($mode == self::MODE_CONNECT) {
            $func = 'connect';
        }

        if (is_string($dsn)) {
            $dsn = array($dsn);
        }

        if (!is_array($dsn)) {
            throw new \RuntimeException('DSN should be a string or an array.');
        }

        foreach ($dsn as $d) {
            if (!is_string($d)) {
                throw new \RuntimeException('Non-string in DSN array detected.');
            }
            $socket->$func($d);
        }
    }
public function connect ( ZMQSocket $ socket , $ mode , $ dsn ) { if ( $ mode == self :: MODE_CONSTRUCT ) { return $ this ; } $ func = null ; if ( $ mode == self :: MODE_BIND ) { $ func = 'bind' ; } elseif ( $ mode == self :: MODE_CONNECT ) { $ func = 'connect' ; } if ( is_string ( $ dsn ) ) { $ dsn = array ( $ dsn ) ; } if ( ! is_array ( $ dsn ) ) { throw new \ RuntimeException ( 'DSN should be a string or an array.' ) ; } foreach ( $ dsn as $ d ) { if ( ! is_string ( $ d ) ) { throw new \ RuntimeException ( 'Non-string in DSN array detected.' ) ; } $ socket -> $ func ( $ d ) ; } }
Connects or binds a socket based on mode.

@param ZMQSocket    $socket
@param string       $mode
@param string|array $dsn

@return \AlphaRPC\Common\Socket\Factory
@throws \RuntimeException
Connects or binds a socket based on mode .