Handling the connection
502375
function onConnection() {
  var endpoint = new http2.Endpoint(log, 'CLIENT', {});
  endpoint.pipe(socket).pipe(endpoint);

  // Sending request
  var stream = endpoint.createStream();
  stream.headers({
    ':method': 'GET',
    ':scheme': url.protocol.slice(0, url.protocol.length - 1),
    ':authority': url.hostname,
    ':path': url.path + (url.hash || '')
  });

  // Receiving push streams
  stream.on('promise', function(push_stream, req_headers) {
    var filename = path.join(__dirname, '/push-' + push_count);
    push_count += 1;
    console.error('Receiving pushed resource: ' + req_headers[':path'] + ' -> ' + filename);
    push_stream.pipe(fs.createWriteStream(filename)).on('finish', finish);
  });

  // Receiving the response body
  stream.pipe(process.stdout);
  stream.on('end', finish);
}
333958
def _handler(self, conn):
        
        incoming = self.recv(conn)
        self.log(DEBUG, incoming)
        try:
            # E.g. ['twister', [7, 'invert'], {'guess_type': True}]
            task, args, kw = self.codec.decode(incoming)
            
            # OK, so we've received the information. Now to use it.
            self.log(INFO, 'Fulfilling task %r' % task)
            self.started_task()
            
            pass_backend = False
            obj = self.tasks[task]
            if _is_iter(obj):
                # (callable, bool)
                obj, pass_backend = obj
            if pass_backend:
                # Have to do this, since args is a list
                args = [self] + args
            
            # Get and package the result
            res = ['success', obj(*args, **kw)]
        except Exception as e:
            self.log(ERROR, 'Error while fullfilling task %r: %r' % (task, e))
            res = ['error', e.__class__.__name__, e.args]
            if self.tracebacks:
                show_err()
        else:
            self.log(INFO, 'Finished fulfilling task %r' % task)
        finally:
            self.send(conn, self.codec.encode(res))
            self.finished_task()
            conn.close()
234965
def on_connect(self, connection):
        
        self._sock = connection._sock
        self._buffer = SocketBuffer(self._sock, self.socket_read_size)        
        if connection.decode_responses:
            self.encoding = connection.encoding
683806
function(callback) {
      self._getConnection(function(err, connection) {
        if (err) {
          callback(new Error('Unable to establish connection with the master ' +
                             'process'));
          return;
        }

        self._connection = connection;
        callback();
      });
    }
507053
def handle(self):
        
        logger = StreamHandler.logger
        logger.debug("handling requests with message handler %s " % StreamHandler.message_handler.__class__.__name__)

        message_handler = StreamHandler.message_handler

        try:
            while True:
                logger.debug('waiting for more data')
                if not message_handler.handle(self.request, StreamHandler.BUFFER_SIZE):
                    break

            logger.warning("connection closed from %s" % (self.client_address[0]))
            self.request.close()
        except:
            logger.exception("connection closed from %s" % (self.client_address[0]))
        finally:
            self.request.close()
798649
private function processConnection()
	{
		$builder = $this->getContainerBuilder();

		$connection = $builder->addDefinition($this->prefix('connection'))
			->setClass(Connection::class)
			->setFactory(DriverManager::class . '::getConnection', [$this->config['connection']]);
	}
323085
def on_open(self, _handle):
        
        self.logger.debug('Connection opened')
        self.handle.add_on_connection_blocked_callback(self.on_blocked)
        self.handle.add_on_connection_unblocked_callback(self.on_unblocked)
        self.handle.add_on_close_callback(self.on_closed)
        self.handle.channel(self.on_channel_open)
550245
def handle_request(self):
        
        try:
            (request, client_address) = self.get_request()

        except socket.error as e:
            # Error handling goes here.
            self.logger.error("error opening the connection: %s" % (
                str(e)))
            for exctn in sys.exc_info():
                print(exctn)
            return

        try:
            self.RequestHandlerClass(request, client_address, self)
        except Exception as e:
            # Error handling goes here.
            self.logger.error('error handling the request: %s' % (
                str(e)))
            for exctn in sys.exc_info():
                print(exctn)
            return
1246732
def listen(self):
        

        # Make sure we're in server mode
        if self.mode and self.mode != 'server':
            raise ValueError("%s is not in server mode" %
                             self.__class__.__name__)
        self.mode = 'server'

        # Obtain a listening socket
        serv = _create_server(self.host, self.port)

        # If we have too many errors, we want to bail out
        err_thresh = 0
        while True:
            # Accept a connection
            try:
                sock, addr = serv.accept()
            except Exception as exc:
                err_thresh += 1
                if err_thresh >= self.max_err_thresh:
                    LOG.exception("Too many errors accepting "
                                  "connections: %s" % str(exc))
                    break
                continue  # Pragma: nocover

            # Decrement error count on successful connections
            err_thresh = max(err_thresh - 1, 0)

            # Log the connection attempt
            LOG.info("Accepted connection from %s port %s" %
                     (addr[0], addr[1]))

            # And handle the connection
            eventlet.spawn_n(self.serve, self.connection_class(sock), addr)

        # Close the listening socket
        with utils.ignore_except():
            serv.close()
973776
function _handleConnection(client) {
	client.on('message', curry(_handleMessage, client))
	client.on('disconnect', curry(_handleDisconnect, client))
	client.pubsub = _engine.getPubSub()
	_emitter.emit('client_connect', client)
}
35600
public function onReady()
    {
        if ($this->pool->config->protologging->value) {
            Daemon::log("New connection\n\n");
        }
        $e = explode('.', $this->protover);
        $packet = pack('nn', $e[0], $e[1]);

        if (strlen($this->user)) {
            $packet .= "user\x00" . $this->user . "\x00";
        }

        if (strlen($this->dbname)) {
            $packet .= "database\x00" . $this->dbname . "\x00";
        }
        elseif (strlen($this->path)) {
            $packet .= "database\x00" . $this->path . "\x00";
        }

        if (strlen($this->options)) {
            $packet .= "options\x00" . $this->options . "\x00";
        }

        $packet .= "\x00";
        $this->sendPacket('', $packet);
    }
970327
def _manipulate(self, *args, **kwargs):
        
        self.connection._manipulate(self, *args, **kwargs)
166581
def connect(self):
        '''
        
        '''
        if self.connected:
            raise RuntimeError(
                '{} is connected already'.format(self.__class__.__name__))
        if self.closed:
            raise RuntimeError(
                '{} is closed already'.format(self.__class__.__name__))
        self.connected = True
        self._connect()
790447
def _handle_event(self, connection, event):
        
        with self.mutex:
            matching_handlers = sorted(
                self.handlers.get("all_events", [])
                + self.handlers.get(event.type, [])
            )
            for handler in matching_handlers:
                result = handler.callback(connection, event)
                if result == "NO MORE":
                    return
59400
private void onConnectSucceeded(){
        LOGGER.info("Accepted the connection.");

        isConnected = true;
        isConnecting = false;
        enableReadOnly();
        synchronized(connectHolder){
            connectHolder.notifyAll();
        }
    }
380476
def connect(self):
        '''
        
        '''
        self._connect()

        try:
            self._listen()
        except (KeyboardInterrupt, SystemExit):
            pass
        finally:
            self.close()
589084
function handleConnection(self, options) {
	if (TRACE)	console.log('Connected to ' + options.host + ':' + options.port)
    	//self.socket = socket;
	self.emit("connect");
}