Forwards a connection to the specified host / port using the proxy protocol.
@param ConnectionInterface $connection
@param string $forwardAddress The host to forward to
@param int $forwardPort The port to forward to
@return Promise
974943
public function forward(ConnectionInterface $connection, $forwardAddress, $forwardPort, $protocolVersion = 2)
    {
        if ($connection instanceof PortConnection) {
            $sourceAddress = $connection->getSourceAddress();
            $sourcePort = $connection->getSourcePort();
            $targetAddress = $connection->getTargetAddress();
            $targetPort = $connection->getTargetPort();
        } elseif ($connection instanceof Connection) {
            list($sourceAddress, $sourcePort) = explode(':', stream_socket_get_name($connection->stream, true));
            list($targetAddress, $targetPort) = explode(':', stream_socket_get_name($connection->stream, false));
        } else {
            throw new \InvalidArgumentException("This connection type is not supported.");
        }

        $connection->pause();

        $header = Header::createForward4($sourceAddress, $sourcePort, $targetAddress, $targetPort, $protocolVersion);
        /** @var Promise $promise */
        $promise = $this->connector->create($forwardAddress, $forwardPort);
        return $promise
            ->then(function(Stream $forwardedConnection) use (
                $connection, $header,
                $sourceAddress, $sourcePort,
                $targetAddress, $targetPort
            ) {
                $forwardedConnection->pause();
                $forwardedConnection->getBuffer()->once('full-drain', function() use ($connection, $forwardedConnection) {
                    $this->emit('forward', [$connection, $forwardedConnection]);
                    $connection->pipe($forwardedConnection);
                    $forwardedConnection->pipe($connection);
                    $connection->resume();
                    $forwardedConnection->resume();
                });
                $forwardedConnection->write($header);

        });
    }
1278003
protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands)
    {
        foreach ($commands as $command) {
            $connection->writeRequest($command);
        }

        $responses = array();
        $exceptions = $this->throwServerExceptions();

        while (!$commands->isEmpty()) {
            $command = $commands->dequeue();
            $response = $connection->readResponse($command);

            if (!$response instanceof ResponseInterface) {
                $responses[] = $command->parseResponse($response);
            } elseif ($response instanceof ErrorResponseInterface && $exceptions) {
                $this->exception($connection, $response);
            } else {
                $responses[] = $response;
            }
        }

        return $responses;
    }
855563
public function setForwardFunction($forwardFunction)
    {
        // If it's the same as any thing in the chain, drop it.
        if ($forwardFunction == $this->getForwardFunction()) {
            return $this;
        }
        $this->forwardFunction = $forwardFunction;

        return $this;
    }
718474
public ApiSuccessResponse forward(ForwardData forwardData) throws ApiException {
        ApiResponse<ApiSuccessResponse> resp = forwardWithHttpInfo(forwardData);
        return resp.getData();
    }
442398
private function registerClient(Connection $connection, $timeout)
    {
        $deferred = new Deferred();

        $responseTimer = $this->loop->addTimer(
            $timeout,
            function () use ($deferred, $timeout) {
                $exception = new \RuntimeException(sprintf('No response after %d seconds.', $timeout));
                $deferred->reject($exception);
            }
        );

        $this->startFlow(new OutgoingConnectFlow($connection, $this->identifierGenerator), true)
            ->always(function () use ($responseTimer) {
                $this->loop->cancelTimer($responseTimer);
            })->then(function (Connection $connection) use ($deferred) {
                $this->timer[] = $this->loop->addPeriodicTimer(
                    floor($connection->getKeepAlive() * 0.75),
                    function () {
                        $this->startFlow(new OutgoingPingFlow());
                    }
                );

                $deferred->resolve($connection);
            })->otherwise(function (\Exception $e) use ($deferred) {
                $deferred->reject($e);
            });

        return $deferred->promise();
    }
242146
public function onRequest(ConnectionInterface $incoming)
    {
        $this->handledRequests++;

        $handler = new RequestHandler($this->socketPath, $this->loop, $this->output, $this->slaves, $this->maxExecutionTime);
        $handler->handle($incoming);
    }
795695
public function forward($busOrEvent, $event=null)
    {
        // If another bus was passed here, we forward from another bus to this
        // one here
        if ($busOrEvent instanceof HasListeners) {
            $forward = new EventForward($busOrEvent, $event);
            return $forward->setTarget($this->root);
        }

        if ($event) {
            throw new LogicException('If you pass no other bus as source, you cant specify an event');
        }

        return new EventForward($this->root, $busOrEvent);
    }
542553
public PortForwardResult forward(String namespace, String name, List<Integer> ports)
      throws ApiException, IOException {
    String path = makePath(namespace, name);
    WebSocketStreamHandler handler = new WebSocketStreamHandler();
    PortForwardResult result = new PortForwardResult(handler, ports);
    List<Pair> queryParams = new ArrayList<>();
    for (Integer port : ports) {
      queryParams.add(new Pair("ports", port.toString()));
    }
    WebSockets.stream(path, "GET", queryParams, apiClient, handler);

    // Wait for streams to start.
    result.init();

    return result;
  }
683159
public function execute(ConnectionInterface $connection, array $argv)
    {

        // initialize input/output instances
        $input = new ArgvInput($argv);
        $output = new BufferedOutput();

        // initialize the execution context
        $executionContext = new ExecutionContext();
        $executionContext->injectInput($input);
        $executionContext->injectOutput($output);
        $executionContext->injectApplication($this->getApplication());

        // start the execution context
        $executionContext->start();
        $executionContext->join();

        // write the result back to the connection
        $executionContext->write($connection);
    }
1179800
protected function addForwardTrigger(Connection $connection, string $name, string $table, string $time, string $event, string $statements): void
    {
        $this->addTrigger($connection, $name, $table, $time, $event, $statements, '');
    }
1180852
private function establishConnection($host, $port, $timeout)
    {
        $deferred = new Deferred();

        $timer = $this->loop->addTimer(
            $timeout,
            function () use ($deferred, $timeout) {
                $exception = new \RuntimeException(sprintf('Connection timed out after %d seconds.', $timeout));
                $deferred->reject($exception);
            }
        );

        $this->connector->connect($host.':'.$port)
            ->always(function () use ($timer) {
                $this->loop->cancelTimer($timer);
            })
            ->then(function (DuplexStreamInterface $stream) use ($deferred) {
                $stream->on('data', function ($data) {
                    $this->handleReceive($data);
                });

                $stream->on('close', function () {
                    $this->handleClose();
                });

                $stream->on('error', function (\Exception $e) {
                    $this->handleError($e);
                });

                $deferred->resolve($stream);
            })
            ->otherwise(function (\Exception $e) use ($deferred) {
                $deferred->reject($e);
            });

        return $deferred->promise();
    }
913859
public function forward(array $to, $return = false): ResponseInterface
    {
        if ($return) {
            $this->app->params($to['params'] ?? null);

            return $this->app->handle(
                $this->app->handler($to)
            );
        }

        $forward = new ActionForward();
        $forward->setForwardTo($to);

        throw $forward;
    }
1367539
public function onConnectGateway($connection)
    {
        $this->gatewayConnections[$connection->remoteAddress] = $connection;
        unset($this->_connectingGatewayAddresses[$connection->remoteAddress], $this->_waitingConnectGatewayAddresses[$connection->remoteAddress]);
    }
485119
public function onConnection(ConnectionInterface $connection)
    {
        $this->log('New connection from ' . $connection->getRemoteAddress());

        $buffer = '';
        $connection->on('data', function ($data) use (&$buffer, &$connection) {
            $buffer .= $data;

            if (strpos($buffer, Client::END_OF_COMMAND)) {
                $chunks = explode(Client::END_OF_COMMAND, $buffer);
                $count = count($chunks);
                $buffer = $chunks[$count - 1];

                for ($i = 0; $i < $count - 1; $i++) {
                    $command = json_decode($chunks[$i], true);
                    $this->runCommand($command, $connection);
                }
            }
        });
    }
1188907
public function forward(Argument $args)
    {
        $args = $this->protectArgs($args);
        $limit = $args['first'];
        $offset = $this->connectionBuilder->getOffsetWithDefault($args['after'], 0);

        // If we don't have a cursor or if it's not valid, then we must not use the slice method
        if (!\is_numeric($this->connectionBuilder->cursorToOffset($args['after'])) || !$args['after']) {
            $entities = \call_user_func($this->fetcher, $offset, $limit ? $limit + 1 : $limit);

            return $this->handleEntities($entities, function ($entities) use ($args) {
                return $this->connectionBuilder->connectionFromArray($entities, $args);
            });
        } else {
            $entities = \call_user_func($this->fetcher, $offset, $limit ? $limit + 2 : $limit);

            return $this->handleEntities($entities, function ($entities) use ($args, $offset) {
                return $this->connectionBuilder->connectionFromArraySlice($entities, $args, [
                    'sliceStart' => $offset,
                    'arrayLength' => $offset + \count($entities),
                ]);
            });
        }
    }
406868
public function addConnection(PdoConnectionInterface $connection)
  {
    $this->connections[\strtolower($connection->getName())] = $connection;

    return $connection;
  }
1231459
function forward(doc){

	if( doc && doc['entity'] && doc['category'] ){

	    // Erase any val, change the placeholder (to try and
	    // prevent races where the user selects and then hits
	    // "search" before the forwarding finishes).
	    jQuery('#' + wired_name).val('');
	    jQuery('#' + wired_name).attr('placeholder', 'Forwarding to ' +
					  doc['entity'] + '...');

	    // Forward to the new doc.
	    if( doc['category'] === 'ontology_class' ){
		window.location.href =
		    linker.url(doc['entity'], 'term');
	    }else if( doc['category'] === 'bioentity' ){
		window.location.href = linker.url(doc['entity'], 'gp');
	    }
	}
    }