BEIJING — Vietnam's president was being feted by China's leaders on a visit through Friday as Beijing continues to shun another rival for South China Sea territory that has challenged its claims on legal grounds, the Philippines.

President Truong Tan Sang is on a three-day visit to boost economic ties with China, Vietnam's communist ally and biggest trading partner. How to manage their disputed territorial sea claims — which last month led to a damaged fishing boat and allegations of a crew's lives being put at risk — is also on the agenda.

China and Vietnam agreed on Wednesday to set up a hotline to resolve fishing incidents in their disputed waters. Both sides should inform the other of any detentions or incidents involving fishermen or fishing boats within 48 hours.

China claims virtually the entire South China Sea and its island groups, while Vietnam and other Southeast Asian countries claim some areas. The islands sit amid some of the world's busiest commercial sea lanes, along with rich fishing grounds and potential oil and gas deposits.

The claims are longstanding but new skirmishes have erupted in the last two years between China and Vietnam and the Philippines.

Last month, Vietnam accused China of damaging a fishing boat that it said was operating in Vietnamese waters, risking the lives of 15 crew members. China said the Vietnamese fishing boat was fishing illegally around islands in Chinese waters. Earlier this month, anti-China protesters staged a show of dissent in Vietnam's capital, demonstrating the domestic pressure its government faces when dealing with China's territorial claims.

China has painted a more consolatory picture with Vietnam than with the Philippines, which made the daring move earlier this year to legally challenge China's vast claims before a tribunal under the United Nations Convention on the Law of the Sea. China has ignored the move.

China wants the disputes settled by negotiating one on one with each of the rival claimants, something that will give it an advantage because of its sheer size.

"Of course it is desirable for China to set up fishing hotlines with other countries if such agreements can be reached, but the problem is it's even more difficult to sit down for negotiations with countries like the Philippines," said Li Jinming of the Institute for South China Sea Studies at Xiamen University.

President Sang met his counterpart Xi Jinping on Wednesday. In remarks carried by the official Xinhua News Agency, Xi said the countries should seek a political solution and not let the issue affect bilateral ties. On Thursday, he was meeting Premier Li Keqiang.