RYAN GOSLING has an un­likely rival for his sexpot GF EVA MENDES’ affection – chrome-domed 65 year old comic Larry David!

The “Sin City” hottie kicked off the improbable three­some when she tapped out a gushing text to a pal named “David,” and accidentally sent it to the “Curb Your Enthusi­asm” star, according to sources.

“Eva wrote a text to her friend David, who’s an aspiring playwright, con­gratulating him on his writing ability and saying that he’s got a big future,” said an insider.

“BUT after sending the text, Eva realized it had gone to Larry David, not her pal David.

“When Ryan found out, he hit the roof! To him, Eva’s inadvertent text meant only one thing – Larry David is on her mind!”

And as The ENQUIRER reported in July 2011, the 39-year-old Cuban- American beauty and the “Seinfeld” co-creator, 65, have a history.

The two built an unlikely bond after hitting it off at a TinselTown party in early 2011 but went their separate ways after several months. Eva has always had a thing for Larry because she loves his intellect and humor.

Eva soon fell for Ryan, 32, when they filmed “The Place Beyond the Pines” al­most two years ago. But the source says she talked constantly about Larry early in their romance.

“Ryan figured that after a few months, Eva’s fascination with Larry would fade, and he’d never hear the guy’s name again,” explained the insider.

But in September 2012, Eva and Larry – who’s divorced and worth an estimated $500 million – reunited while filming the HBO film “Clear History,” and they apparently re-established their friendship.

“Ryan doesn’t want Eva to think he’s jealous of Larry, but the truth is, he IS jealous of Larry,” said the insider.

“After all, Larry’s not a bad looking guy and he’s rich! Women are con­stantly falling at his feet.

“Ryan just hopes Eva will ‘curb her enthusiasm’ for him sooner rather than later.”