6. A drawer contains red and blue socks, with a total number not exceeding 2017. If two socks are randomly drawn, the probability that they are the same color is $\frac{1}{2}$. What is the maximum number of red socks in the drawer? $\qquad$
6.990

Analysis: Let $x, y$ be the number of red and blue socks in the drawer, respectively. Since the probability of picking two socks of different colors is $\frac{1}{2}$, we have $\frac{x y}{C_{x+y}^{2}}=\frac{1}{2}$, which simplifies to $(x-y)^{2}=x+y$. Therefore, the total number of socks is a perfect square. Let $n=x-y$, then $n^{2}=x+y$, so $x=\frac{n^{2}+n}{2}$. Given that $x+y \leq 2017$, we have $n \leq 44$ and $x \leq 990$. Therefore, the maximum number of red socks in the drawer is 990.