A drawer contains a mixture of red socks and blue socks, at most 1991 in all. It so happens that, when two socks are selected randomly without replacement, there is a probability of exactly $1/2$ that both are red or both are blue. What is the largest possible number of red socks in the drawer that is consistent with this data?
1. Let \( a \) be the number of red socks and \( b \) be the number of blue socks. The total number of socks is \( a + b \leq 1991 \).

2. The problem states that the probability of selecting two socks of the same color (both red or both blue) is exactly \( \frac{1}{2} \). This can be expressed as:
   \[
   \frac{\binom{a}{2} + \binom{b}{2}}{\binom{a+b}{2}} = \frac{1}{2}
   \]

3. Expanding the binomial coefficients, we get:
   \[
   \binom{a}{2} = \frac{a(a-1)}{2} \quad \text{and} \quad \binom{b}{2} = \frac{b(b-1)}{2}
   \]
   \[
   \binom{a+b}{2} = \frac{(a+b)(a+b-1)}{2}
   \]

4. Substituting these into the probability equation, we have:
   \[
   \frac{\frac{a(a-1)}{2} + \frac{b(b-1)}{2}}{\frac{(a+b)(a+b-1)}{2}} = \frac{1}{2}
   \]

5. Simplifying the equation, we get:
   \[
   \frac{a(a-1) + b(b-1)}{(a+b)(a+b-1)} = \frac{1}{2}
   \]

6. Multiplying both sides by \( 2(a+b)(a+b-1) \), we obtain:
   \[
   2(a(a-1) + b(b-1)) = (a+b)(a+b-1)
   \]

7. Expanding and simplifying, we get:
   \[
   2a^2 - 2a + 2b^2 - 2b = a^2 + 2ab + b^2 - a - b
   \]
   \[
   2a^2 + 2b^2 - 2a - 2b = a^2 + 2ab + b^2 - a - b
   \]
   \[
   a^2 - 2ab + b^2 = a + b
   \]

8. Recognizing the left-hand side as a perfect square, we have:
   \[
   (a - b)^2 = a + b
   \]

9. Let \( a + b = n^2 \) for some positive integer \( n \). Then \( (a - b)^2 = n^2 \), so \( a - b = \pm n \).

10. To maximize \( a \), we take \( a - b = n \). Solving for \( a \) and \( b \), we get:
    \[
    a = \frac{n^2 + n}{2} \quad \text{and} \quad b = \frac{n^2 - n}{2}
    \]

11. Since \( a + b \leq 1991 \), we have:
    \[
    n^2 \leq 1991
    \]
    The largest integer \( n \) such that \( n^2 \leq 1991 \) is \( n = 44 \) (since \( 44^2 = 1936 \) and \( 45^2 = 2025 \)).

12. Substituting \( n = 44 \) into the expression for \( a \), we get:
    \[
    a = \frac{44^2 + 44}{2} = \frac{1936 + 44}{2} = \frac{1980}{2} = 990
    \]

The final answer is \( \boxed{990} \).