Shares of BroadSoft Inc. soared 21 percent in after-hours trading Monday as the communications software company reported better second-quarter earnings than management and analysts expected.

The results surprised investors after the company offered a downbeat outlook a few months ago. Those projections triggered a massive sell-off that caused BroadSoft's shares to plummet by more than 30 percent in less than a week in May.

In the three-month period ending in June, BroadSoft earned $2.4 million, or 8 cents per share, compared with net income of $15.8 million, or 57 cents per share, at the same time last year. The year-ago results included an income tax benefit of $9.9 million, or 36 cents per share.

Without some one-time items, BroadSoft said it would have earned 33 cents per share. The company had predicted adjusted earnings of 17 cents to 23 cents per share. And analysts forecast 21 cents per share, according to FactSet.

Revenue for the period climbed 26 percent from last year to $40.5 million. The company forecast revenue of $36 million to $38 million. Analysts looked for $37.3 million.

In the current quarter, BroadSoft expects adjusted earnings of 27 to 33 cents per share on revenue of $40 million to $42 million.

The average analyst forecast calls for third-quarter adjusted earnings of 31 cents per share on revenue of $39.9 million.

BroadSoft also announced that it is expanding its product line with an acquisition. The company is paying $22 million for the assets of Adaption Technologies Ventures Ltd., which provides tools for talking through Internet connections, according to a regulatory filing.

BroadSoft expects Adaption to generate an additional $500,000 in revenue and add 2 cents per share to earnings in the current quarter ending in September.

Broadsoft shares rose $5.85, or 21 percent, to $33.75 in after-hours trading. They closed up $1.41, or 5.3 percent, at $27.90 in the regular session.