Once the channel becomes active, sends the initial open connection request.
505406
@Override
  public void channelActive(final ChannelHandlerContext ctx) throws Exception {
    ByteBuf request = ctx.alloc().buffer();
    VersionRequest.init(request);
    ctx.writeAndFlush(request);
  }
395645
public void sendStart() throws SIConnectionDroppedException, SIConnectionLostException {                     //471642
     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "start");
     sendStart(false);            // Always use proper start
     if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "start");
   }
728789
def open(self):
		
		if self.connection:
			# Nothing to do if the connection is already open.
			return False

		self.connection = self._get_twilio_client()
		return True
1315357
public void startProxy() {
		if(this.ackReceived) 
			throw new IllegalStateException("Can't start. ACK has been received.");
		if(!this.originalRequest.isInitial())
			throw new IllegalStateException("Applications should not attempt to " +
					"proxy subsequent requests. Proxying the initial request is " +
					"sufficient to carry all subsequent requests through the same" +
					" path.");

		// Only send TRYING when the request is INVITE, needed by testProxyGen2xx form TCK (it sends MESSAGE)
		if(this.originalRequest.getMethod().equals(Request.INVITE) && !started) {
			// Send provisional TRYING. Chapter 10.2
			// We must send only one TRYING no matter how many branches we spawn later.
			// This is needed for tests like testProxyBranchRecurse
//			tryingSent = true;
			TransactionState transactionState = null;
			if(originalRequest.getTransaction() != null) {
				transactionState = originalRequest.getTransaction().getState();
			}
			// Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2417
			// Two 100 Trying responses sent if Proxy decision is delayed.
			if (transactionState == null || transactionState == TransactionState.TRYING) {
				if(originalRequest.getTransaction().getState() == null )
				logger.info("Sending 100 Trying to the source");
				SipServletResponse trying =
					originalRequest.createResponse(100);			
				try {
					trying.send();
				} catch (IOException e) { 
					logger.error("Cannot send the 100 Trying",e);
				}
			}
		}
		
		
		started = true;
		if(this.parallel) {
			for (final MobicentsProxyBranch pb : this.proxyBranches.values()) {
				if(!pb.isStarted()) {
					pb.start();
				}
			}
		} else {
			startNextUntriedBranch();
		}		
	}
1000700
protected function onStart()
    {
        do {
            // Disconnect and reconnect
            $this->reconnect();

            // If we successfully connected and we're supposed to be running,
            // call the onConnect event
            if ($this->_conn && ! feof($this->_conn) && $this->_state == parent::STATE_RUNNING) {
                $this->onConnect();
            }

            // Params for stream_select
            $read = array($this->_conn);
            $write = null;
            $except = null;

            $buf = '';

            // Loop while the connection is valid using stream_select with a
            // timeout. The timeout allows us to check to see if a stop has been
            // requested.
            while ($this->_conn && ! feof($this->_conn) &&
                ($count = stream_select($read, $write, $except, $this->_read_timeout))) {
                // Only continue if we're in the right state
                if ($this->_state != parent::STATE_RUNNING) {
                    break;
                }

                if (! $count) {
                    // Nothing waiting, listen again
                    continue;
                }

                // Set the stream as blocking
                stream_set_blocking($this->_conn, 1);
                stream_set_timeout($this->_conn, $this->_stream_timeout);

                // Get the chunk length
                $len = fgets($this->_conn, $this->_max_line_length);
                if ($len === false) {
                    // EOF
                    continue;
                }

                // Read and process each line
                while ($this->_state == parent::STATE_RUNNING &&
                    ($line = fgets($this->_conn, $this->_max_line_length)) !== false) {
                    if (strlen($line) == 0) {
                        // End of the chunk
                        break;
                    }

                    $this->onData($line);
                }

                // Set the stream as non-blocking
                if ($this->_conn) {
                    stream_set_blocking($this->_conn, 0);
                }
            }

            $this->onDisconnect();
        } while ($this->_conn && (! feof($this->_conn) || $this->_auto_reconnect) &&
            $this->_state == parent::STATE_RUNNING);

        // Make sure we're properly disconnected and in a known state
        $this->disconnect();

        // We've stopped for some reason, figure out why
        if ($this->_state == parent::STATE_STOPPING) {
            $reason = 'Stop requested';
        } else {
            $reason = 'Connection dropped';
        }

        // Now tell the user
        $this->onStop($reason);
    }
185151
def on_welcome(self, connection, event):
        
        connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
559164
def open(self):
        '''
        
        '''
        args = Writer()
        args.write_shortstr('')
        self.send_frame(MethodFrame(self.channel_id, 20, 10, args))
        self.channel.add_synchronous_cb(self._recv_open_ok)
787523
public T open(RequestChannel channel)
    {
        return clientManager.createClient(channel, clientType, clientName, eventHandlers);
    }
573644
synchronized void openConnection(final ModelController controller, final ActiveOperation.CompletedCallback<ModelNode> callback) throws Exception {
        boolean ok = false;
        final Connection connection = connectionManager.connect();
        try {
            channelHandler.executeRequest(new ServerRegisterRequest(), null, callback);
            // HC is the same version, so it will support sending the subject
            channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IDENTITY, Boolean.TRUE);
            channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IN_VM, Boolean.TRUE);
            channelHandler.addHandlerFactory(new TransactionalProtocolOperationHandler(controller, channelHandler, responseAttachmentSupport));
            ok = true;
        } finally {
            if(!ok) {
                connection.close();
            }
        }
    }
1249244
void establishConnection () throws IOException {
        synchronized (operationOnConnectionMonitor) {
            if (state == State.CLOSED) {
                throw new IOException("Attempt to establish a connection with a closed connection factory");
            } else if (state == State.CONNECTED) {
                LOGGER.warn("Establishing new connection although a connection is already established");
            }
            try {
                LOGGER.info("Trying to establish connection to {}:{}", getHost(), getPort());
                connection = super.newConnection(executorService);
                connection.addShutdownListener(connectionShutdownListener);
                LOGGER.info("Established connection to {}:{}", getHost(), getPort());
                changeState(State.CONNECTED);
            } catch (IOException e) {
                LOGGER.error("Failed to establish connection to {}:{}", getHost(), getPort());
                throw e;
            }
        }
    }
283611
def open_connection(request)
      connection = ConnectionAdapters.establish_connection(request, dispatcher)

      assign_connection_id connection
      register_user_connection connection

      connections[connection.id] = connection

      info "Connection opened: #{connection}"
      connection.rack_response
    end
198885
protected void startOutgoingConnection (final Connection conn, InetSocketAddress addr)
    {
        final SocketChannel sockchan = conn.getChannel();
        try {
            // register our channel with the selector (if this fails, we abandon ship immediately)
            conn.selkey = sockchan.register(_selector, SelectionKey.OP_CONNECT);

            // start our connection process (now if we fail we need to clean things up)
            NetEventHandler handler;
            if (sockchan.connect(addr)) {
                _outConnValidator.validateOutgoing(sockchan); // may throw
                // it is possible even for a non-blocking socket to connect immediately, in which
                // case we stick the connection in as its event handler immediately
                handler = conn;

            } else {
                // otherwise we wire up a special event handler that will wait for our socket to
                // finish the connection process and then wire things up fully
                handler = new OutgoingConnectionHandler(conn);
            }
            _handlers.put(conn.selkey, handler);

        } catch (IOException ioe) {
            log.warning("Failed to initiate connection for " + sockchan + ".", ioe);
            conn.connectFailure(ioe); // nothing else to clean up
        }
    }
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }
978158
def on_connect(self, connection):
        ""
        self._sock = connection._sock
        self._buffer = SocketBuffer(self._sock, self.socket_read_size)
        self.encoder = connection.encoder
787791
def on_connect(client):
    """"""
    client.nick(client.user.nick)
    client.userinfo(client.user.username, client.user.realname)
371193
public void onStateChange() {
        switch (dataChannel.state()) {
            case CONNECTING:
                break;

            case OPEN: {
                    if (null != callReference) {
                        RespokeCall call = callReference.get();
                        if (null != call) {
                            call.directConnectionDidOpen(this);
                        }
                    }

                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    public void run() {
                        if (null != listenerReference) {
                            Listener listener = listenerReference.get();
                            if (null != listener) {
                                listener.onOpen(RespokeDirectConnection.this);
                            }
                        }
                    }
                });
                }
                break;

            case CLOSING:
                break;

            case CLOSED: {
                    if (null != callReference) {
                        RespokeCall call = callReference.get();
                        if (null != call) {
                            call.directConnectionDidClose(this);
                        }
                    }

                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        public void run() {
                            if (null != listenerReference) {
                                Listener listener = listenerReference.get();
                                if (null != listener) {
                                    listener.onClose(RespokeDirectConnection.this);
                                }
                            }
                        }
                    });
                }
                break;
        }
    }
1239903
void handleInitialRequest(HttpServerExchange initial, Http2Channel channel, byte[] data) {

        //we have a request
        Http2HeadersStreamSinkChannel sink = channel.createInitialUpgradeResponseStream();
        final Http2ServerConnection connection = new Http2ServerConnection(channel, sink, undertowOptions, bufferSize, rootHandler);


        HeaderMap requestHeaders = new HeaderMap();
        for(HeaderValues hv : initial.getRequestHeaders()) {
            requestHeaders.putAll(hv.getHeaderName(), hv);
        }
        final HttpServerExchange exchange = new HttpServerExchange(connection, requestHeaders, sink.getHeaders(), maxEntitySize);
        if(initial.getRequestHeaders().contains(Headers.EXPECT)) {
            HttpContinue.markContinueResponseSent(exchange);
        }
        if(initial.getAttachment(HttpAttachments.REQUEST_TRAILERS) != null) {
            exchange.putAttachment(HttpAttachments.REQUEST_TRAILERS, initial.getAttachment(HttpAttachments.REQUEST_TRAILERS));
        }
        Connectors.setRequestStartTime(initial, exchange);
        connection.setExchange(exchange);
        exchange.setRequestScheme(initial.getRequestScheme());
        exchange.setRequestMethod(initial.getRequestMethod());
        exchange.setQueryString(initial.getQueryString());
        if(data != null) {
            Connectors.ungetRequestBytes(exchange, new ImmediatePooledByteBuffer(ByteBuffer.wrap(data)));
        } else {
            Connectors.terminateRequest(exchange);
        }
        String uri = exchange.getQueryString().isEmpty() ? initial.getRequestURI() : initial.getRequestURI() + '?' + exchange.getQueryString();
        try {
            Connectors.setExchangeRequestPath(exchange, uri, encoding, decode, allowEncodingSlash, decodeBuffer, maxParameters);
        } catch (ParameterLimitException e) {
            exchange.setStatusCode(StatusCodes.BAD_REQUEST);
            exchange.endExchange();
            return;
        }


        handleCommonSetup(sink, exchange, connection);
        Connectors.executeRootHandler(rootHandler, exchange);
    }