Updated

Chicago, IL (SportsNetwork.com) - Gordon Beckham and Dayan Viciedo each smashed two-run homers to help power the Chicago White Sox to an 8-2 win over the San Francisco Giants on Tuesday in the opener of a two-game set.

Adam Eaton, Adam Dunn and Tyler Flowers all drove in a run for the White Sox, who snapped a four-game skid.

John Danks (6-5), who has won three straight starts, tossed a solid 6 1/3 innings, allowing two runs -- one earned -- on five hits and three walks with four strikeouts.

"He has pitched to where he is always giving us a chance out there," said White Sox manager Robin Ventura. "It seems like he has a little more on it when he's spotting his fastball."

In his worst outing of the year, Matt Cain (1-5) was tagged for eight runs -- seven earned -- on 10 hits and a walk over just five innings to absorb the loss.

Hunter Pence had a solo home run and Buster Posey added an RBI for the Giants, who have dropped a season-high four straight and seven of their last eight.

The game was tied 2-2 before Chicago pulled away after scoring three runs in the fourth and fifth innings.

Three singles to left in the fourth loaded the bases for the White Sox with one out. Cain issued his first walk of the game to Flowers with two outs that put Chicago up 3-2.

Eaton then singled on a slow roller to shortstop Brandon Crawford, whose bare-handed throw to first was wide, which allowed an extra run to score to make it 5-2.

Dunn drove in Conor Gillaspie, who singled to start the fifth on a base hit to right. Viciedo then smacked a two-run homer to increase Chicago's advantage to 8-2.

Earlier, Pence smashed his 10th homer of the year in the first to give the Giants an early 1-0 lead and they pushed across another run in the second. Gregor Blanco drew a walk and Pence reached on shortstop Alexei Ramirez's fielding error. Posey's base hit to left plated Blanco.

Beckham crushed a two-run home run to left in the third with two outs to tie the game. Eaton kept the inning alive with a single.

"The third inning was a little long and he (Cain) ended up giving up the home run then he got derailed," said Giants manager Bruce Bochy.

Game Notes

Eaton has reached base safely in 12 consecutive games ... Cain is winless in his last nine road starts, dating back to last season ... It was the Giants first interleague loss of the season (6-1) ... The Giants went 1-for-5 with runners in scoring position.