This can be shortened a lot. Remove these explicit functions and roll them into getNumConnections. All the cases can be implemented like this this:

    LOCK(cs_vNodes);
    if(flags == CONNECTIONS_ALL) // Shortcut if we want total
        return vNodes.size();
    int nNum = 0;
    BOOST_FOREACH(CNode* pnode, vNodes)
    if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
        nNum++;
    return mNum;

Then the flags values should be:

    enum NumConnections {
        CONNECTIONS_NONE = 0,
        CONNECTIONS_OUT  = (1U << 0),
        CONNECTIONS_IN = (1U << 1),
        CONNECTIONS_ALL  = CONNECTIONS_OUT | CONNECTIONS_IN,
    };