conn established
518958
private function connected() : void
    {
        $this->connected = true;
        while ($this->buffer) {
            $this->client->send(array_shift($this->buffer));
        }
    }
734384
private function parseConn($conn)
    {
        while(true)
        {
            $meta = fread($conn, 4);
            if('' === $meta || false === $meta)
            {
                return;
            }
            $length = unpack('N', $meta)[1];
            $data = fread($conn, $length);
            if(false === $data || !isset($data[$length - 1]))
            {
                return;
            }
            $body = ($this->unserialize)($data);
            if(!$body instanceof Operation)
            {
                return;
            }
            try{
                $result = new Result($this->operationParser->parse($body));
            } catch(\Throwable $th) {
                $result = new Result(null, $th);
            }
            $resultData = ($this->serialize)($result);
            $length = strlen($resultData);
            $resultData = pack('N', $length) . $resultData;
            fwrite($conn, $resultData, $length + 4);
        }
    }
881666
function setup(connection) {

                var request = undefined;
                var reply_to = undefined;
                var response = undefined;

                node.connection = connection;

                // node connected
                node.status({ fill: 'green', shape: 'dot', text: 'connected' });

                node.sender = node.connection.open_sender({ target: {} });

                // build receiver options
                var receiver_options = {
                    source: {
                        address: node.address
                    }
                };
                node.receiver = node.connection.open_receiver(receiver_options);

                node.receiver.on('message', function(context) {

                    // save request and reply_to address on AMQP message received
                    request = context.message;
                    reply_to = request.reply_to;

                    // provides the request and delivery as node output
                    var msg = {
                        payload: context.message,
                        delivery: context.delivery
                    };
                    node.send(msg);
                });

                node.connection.on('disconnected', function(context) {
                    // node disconnected
                    node.status({fill: 'red', shape: 'dot', text: 'disconnected' });
                });

                node.on('input', function(msg) {
                    // enough credits to send
                    if (node.sender.sendable()) {

                        if (reply_to) {

                            // fill the response with the provided one as input
                            response = msg.payload;
                            response.to = reply_to;

                            node.sender.send(response);
                        }
                    }
                });

                node.on('close', function() {
                    if (node.sender != null)
                        node.sender.detach();
                    if (node.receiver != null)
                        node.receiver.detach();
                    node.connection.close();
                })

            }
559694
function (conn, opts) {
            opts = opts || {};
            var s = opts.prepare;
            var logConnectionExecute = comb("__logConnectionExecute");
            if (s) {
                s = this.literal(s);
                var self = this;
                return this.__logConnectionExecute(conn, "XA END " + s)
                    .chain(function () {
                        return self.__logConnectionExecute(conn, "XA PREPARE " + s);
                    })
                    .chain(function () {
                        return self.__logConnectionExecute(conn, "XA ROLLBACK " + s);
                    });
            } else {
                return this._super(arguments);
            }
        }
358651
protected synchronized void setConnection (PresentsConnection conn)
    {
        long now = System.currentTimeMillis();
        if (_conn != null) {
            // if our connection is being cleared out, record the amount of time we were connected
            // to our total connected time
            if (conn == null) {
                _connectTime += ((now - _networkStamp) / 1000);
                _messagesDropped = 0;
            }

            // make damn sure we don't get any more messages from the old connection
            _conn.clearMessageHandler();
        }

        // keep a handle to the new connection
        _conn = conn;

        // if we're setting a connection rather than clearing one out...
        if (_conn != null) {
            // tell the connection to pass messages on to us
            _conn.setMessageHandler(this);

            // configure any active custom class loader
            if (_loader != null) {
                _conn.setClassLoader(_loader);
            }
        }

        // make a note that our network status changed
        _networkStamp = now;
    }
294100
func (n *Network) Conn(c net.Conn) (net.Conn, error) {
	start := now()
	nc := &conn{Conn: c, network: n, readBuf: new(bytes.Buffer)}
	if err := nc.sync(); err != nil {
		return nil, err
	}
	sleep(start.Add(nc.delay).Sub(now()))
	return nc, nil
}
583243
def setup(self):
        """"""
        for table_spec in self._table_specs:
            with self._conn:
                table_spec.setup(self._conn)
587206
def connect(conn)
      start = Time.now
      conn.connect
      @latency = Time.now - start
      @down_at = nil
      true
    end
474678
def register_outgoing_conn(self, conn):
        """"""
        assert conn, "conn is required"
        conn.set_outbound_pending_change_callback(self._on_conn_change)
        self.connections.append(conn)
        self._set_on_close_cb(conn)
        self._on_conn_change()
356668
def new_connection_status(self, conn_status):
        """"""
        if conn_status.status == CONNECTION_STATUS_CONNECTED:
            self._mz.update_members()
        if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or
                conn_status.status == CONNECTION_STATUS_LOST):
            self._mz.reset_members()
272393
def insert(conn, qualified_name: str, column_names, records):
    """"""

    query = create_insert_statement(qualified_name, column_names)

    with conn:
        with conn.cursor(cursor_factory=NamedTupleCursor) as cursor:
            for record in records:
                cursor.execute(query, record)
249798
function makeStream(conn) {
    return function stream(sql, options = { highWaterMark: 5 }) {
        return conn.query(sql).stream(options);
    };
}
739828
function (conns, index) {
                    for (var i = 0; i < conns.length; i++) {
                        var c = conns[i];
                        _expandConnection(c, index, group);
                    }
                }
1093201
function setupWindow(win, conn) {
  win.on('inputChar', function (c, i) {
    if (i === nc.keys.ESC) {
      var items = {};
      for (var i=0; i<connections.length; i++) {
        items[connections[i].client.opt.server] = connections[i].wins.status;
        for (var j=0,chans=Object.keys(connections[i].wins.channels); j<chans.length; j++)
          items['  ' + chans[j]] = connections[i].wins.channels[chans[j]];
        for (var j=0,queries=Object.keys(connections[i].wins.queries); j<queries.length; j++)
          items['  Q:' + queries[j]] = connections[i].wins.queries[queries[j]];
      }
      widgets.ListBox(items,
        {
          title: 'Windows',
          height: Math.min(Object.keys(items).length+2, nc.lines-2),
          style: {
            colors: {
              bg: 'blue',
              fg: 'white'
            }
          }
        }, function(window) {
          if (window)
            window.top();
          nc.redraw();
      });
    } else if (i === nc.keys.BACKSPACE && win.curx > 0) {
      win.inbuffer = win.inbuffer.substring(0, win.curx - 1) + win.inbuffer.substring(win.curx);
      win.delch(win.height-1, win.curx - 1);
      win.refresh();
    } else if (i === nc.keys.DEL) {
      win.inbuffer = win.inbuffer.substring(0, win.curx) + win.inbuffer.substring(win.curx + 1);
      win.delch(win.height-1, win.curx);
      win.refresh();
    } else if (i === nc.keys.LEFT && win.curx > 0) {
      win.cursor(win.height-1, win.curx-1);
      win.refresh();
    } else if (i === nc.keys.RIGHT && win.curx < win.inbuffer.length) {
      win.cursor(win.height-1, win.curx+1);
      win.refresh();
    } else if (i === nc.keys.END) {
      win.cursor(win.height-1, win.inbuffer.length);
      win.refresh();
    } else if (i === nc.keys.HOME) {
      win.cursor(win.height-1, 0);
      win.refresh();
	  } else if (i === nc.keys.NEWLINE) {
	    if (win.inbuffer.length) {
	      if (win.inbuffer[0] === '/') {
  	      var cmd = win.inbuffer.substring(1).split(' ', 1).join('').trim(),
  	          args = win.inbuffer.substring(win.inbuffer.indexOf(cmd)+cmd.length+1).trim();
	        switch (cmd.toLowerCase()) {
            case 'j':
	          case 'join':
              if (args.length) {
                if (args[0] !== '#' && args[0] !== '&'
                    && args[0] !== '+' && args[0] !== '!')
                  args = "#" + args;
                if (args.length > 1 && !conn.wins.channels[args])
                  conn.client.join(args);
              }
	          break;
            case 'part':
              var name = getWinName(win, conn);
              if (name[0] === '#' || name[0] === '&'
                  || name[0] === '+' || name[0] === '!') {
                conn.client.part(name);
                delete conn.wins.channels[name];
              }
            break;
	          case 'msg':
	            var who = args.substring(0, args.indexOf(' ')),
	                message = args.substring(args.indexOf(' ')+1);
	            if (!who.length || !message.length)
	              appendLine(win, 'Invalid arguments');
	            else {
	              conn.client.say(who, message);
	              appendLine(win, '* ->' + who + ': ' + message);
	            }
	          break;
	          case 'me':
	            if (win !== conn.wins.status) {
	              if (args.length) {
                  var key = getWinName(win, conn);
	                conn.client.say(key, CTCP_DELIM + 'ACTION ' + args + CTCP_DELIM);
  	              appendLine(win, '* ' + conn.client.nick + ' ' + args, COLOR_ACTION);
  	            }
	            } else
	              appendLine(win, 'That command is only valid on channel and query windows');
	          break;
            case 'whois':
              if (args.length) {
                conn.client.send('WHOIS', args, false);
              }
            break;
            case 'nick':
              if (args.length) {
                var newnick = args.split(' ', 1).join('');
                if (newnick) {
                  conn.client.prevnick = conn.client.nick;
                  conn.client.send("NICK", newnick);
                  conn.client.nick = newnick;
                }
              }
            break;
            case 'away':
              conn.client.send('AWAY', (args.length ? args : 'I am away'));
              appendLine(conn.wins.status, '* You have been marked as being away', nc.attrs.BOLD);
            break;
            case 'back':
              conn.client.send('AWAY');
              appendLine(conn.wins.status, '* You are no longer marked as being away', nc.attrs.BOLD);
            break;
            case 'exit':
	          case 'quit':
	            if (args.length)
  	            conn.client.disconnect(args);
  	          else
  	            conn.client.disconnect();
	            cleanup();
	          break;
	          case 'close':
	            if (win === conn.wins.status)
	              conn.client.disconnect();
	            else {
                var key = getWinName(win, conn);
                if (key[0] === '#' || key[0] === '&'
                    || key[0] === '+' || key[0] === '!') {
                  conn.client.part(key);
                  delete conn.wins.channels[key];
                } else
                  delete conn.wins.queries[key];
	            }
              win.close();
              nc.redraw();
              if (nc.numwins === 1)
                cleanup();
              return;
	          break;
	          case 'query':
	            var to = args.split(' ', 1).join('');
              if (!conn.wins.queries[to.toLowerCase()]) {
                var query = new nc.Window(nc.lines, nc.cols);
                setupWindow(query, conn);
                updateHeader(query, 'Query: ' + to, {pos: 'center'});
                conn.wins.queries[to.toLowerCase()] = query;
              }
	          break;
            case 'connect':
            break;
            case 'server':
            break;
            case 'whowas':
            break;
            case 'who':
            break;
            case 'info':
            break;
            case 'banlist':
            break;
            case 'notice':
            break;
            case 'invite':
            break;
            case 'ctcp':
            break;
	          default:
  	          appendLine(win, 'Unknown command: ' + cmd);
	        }
	      } else if (win.inbuffer.length && win !== conn.wins.status) {
          var key = getWinName(win, conn);
	        conn.client.say(key, win.inbuffer);
	        appendLine(win, '<' + conn.client.nick + '> ' + win.inbuffer);
	      }
	      win.inbuffer = "";
	      win.cursor(win.height-1, 0);
	      win.clrtoeol();
	      win.refresh();
	    }
	  } else if (i >= 32 && i <= 126 && win.curx < win.width-1) {
	    win.inbuffer = win.inbuffer.slice(0, win.curx) + c + win.inbuffer.slice(win.curx);

	    if (win.curx < win.inbuffer.length) {
	      win.insch(i);
	      win.cursor(win.height - 1, win.curx + 1);
	    } else {
	      win.addch(i);
	    }
	    
	    win.refresh();
	  }
  });
  win.scrollok(true);
  win.hline(win.height-2, 0, win.width);
  win.setscrreg(1, win.height-3); // Leave one line at the top for the header
  win.cursor(win.height-1, 0);
  win.refresh();
  win.inbuffer = "";
}
600432
function createPool(conn) {
  var conf = connectionConfig[conn.app][conn.env];
  conf.connStr = connStr(conn);
  console.log('Creating pool to : ' + conf.connStr);
  // Create the pool on the conf object for easy future access
  conf.pool = anydb.createPool(conf.connStr, {
    min: conf.min,
    max: conf.max,
    onConnect: function (conn, done) {
      done(null, conn);
    },
    reset: function (conn, done) {
      done(null);
    }
  });
  // Remember all connection pools for easy termination
  pools.push(conf.pool);
  return conf.pool;
}
1060828
function (connectionName, collectionName, definition, cb) {

      var connectionObject = connections[connectionName];
      if (!connectionObject) return cb(Errors.InvalidConnection);

      var collection = connectionObject.collections[collectionName];
      if (!collection) return cb(Errors.CollectionNotRegistered);

      collection.createTable(cb);
    }
1322036
private function maybeUpdateRDY(Connection $conn)
    {
        if ($this->inBackoff() || $this->inBackoffTimeout()) {
            return;
        }

        $remainRDY = $conn->getRemainRDY();
        $lastRdyCount = $conn->lastRDY();
        $perConnMax = $this->perConnMaxInFlight();

        if ($remainRDY <= 1 || $remainRDY < ($lastRdyCount / 4) || ($perConnMax > 0 && $perConnMax < $remainRDY)) {
            $this->updateRDY($conn, $perConnMax);
        }
    }