When a wave of ethnic violence swept across this idyllic island republic, Sri Lankan officials, accustomed to dealing with a pliant, state-controlled press, found themselves abruptly besieged by scores of foreign journalists clamoring for information.

Torn between traditional Sri Lankan hospitality and their instinct to put the best possible face on an unflattering situation, the officials groped for an information policy that would satisfy both needs.

But in the end, amid rising attacks by the Sinhalese majority against the Tamil minority that left more than 300 dead and up to 100,000 homeless, they opted for that time-tested remedy for information ministers' headaches--stringent state censorship.

For this correspondent, it was an unsettling reminder of Baghdad in the first tumultuous weeks of the Iraq-Iran war in 1980, and of Tehran in the first heady days of the post-revolutionary Islamic Republic in 1979, when the Iraqi Information Ministry and the Iranian Ministry of National Guidance similarly quarreled with initially sympathetic journalists and also dealt with the problem the only way they knew--by imposing censorship.

Most of the correspondents who descended upon Sri Lanka coped with censorship the way correspondents usually do--first by arguing futilely to change the system, then by applying resourcefulness and ingenuity to circumvent it, and finally by leaving the country to transmit dispatches that had been blocked by the censor.

In the end, the news got out--albeit a bit delayed in many instances--and censorship once again emerged bruised, if not battered.

The managers of Sri Lanka's attempts to censor the foreign press were a no-nonsense middle-aged woman named Nanel Abeyratna, acting director of the Information Ministry's press department, and Douglas Liyanage, the urbane secretary of the Ministry of State.

"Anything connected with security that hasn't been officially released" is how Abeyratna described censorable material when she summoned foreign reporters to her office during the first days of the communal rioting. She proceeded to blue-pencil dispatches submitted to her, in some cases deleting official pronouncements issued at Liyanage's daily press briefings.

Liyanage said the government was only trying to prevent the publication of "distorted and unbalanced" reports, and when informed by angry foreign reporters at one briefing that his own bland official announcements were being deleted by the censor, he promised to look into the matter.

At one point, Liyanage announced a "minor tightening" of censorship, extending it to cover "all material relating to the law and order situation," whether originating in Sri Lanka or any other country, if it was deemed "prejudicial" to national security. The ban was understood to cover references to Tamil-organized demonstrations in India and several European capitals.

Liyanage also announced on Aug. 1 that all photography would be prohibited for two days; that hotel telex operators had been warned not to accept uncensored copy; that curfew passes would be honored only between a reporter's hotel and the censor's office, and that refugee camps housing burned-out Tamil families would be off limits to journalists.

That same day, the censor's office shortened its working hours, making it difficult, if not impossible, to include late-breaking news in dispatches submitted for approval.

Telephone taps on reporters' hotel rooms became more frequent, although they were so flawed technically and so obvious that they could be evaded by moving to another room, or by simply waiting for the automatic monitoring device to scan other telephone extensions at random for conversations.

Despite the clampdown, many correspondents continued to circumvent the censor. Some allowed the censor to delete portions of their dispatches and then telephoned their home offices to "clarify garbled telexes"; some moved from room to room--and even from hotel to hotel--in an effort to avoid the telephone taps; some scoured the airport departure lounge for "pigeons" to take their copy out of the country, and some boarded flights to Singapore and Bombay to file their reports.

One photographer had a portable wirephoto transmitter in his hotel room with which he sent pictures to his home office. When a mystified hotel operator cut into his telephone connection to inquire about the "strange noises" emitting over the line, he barked, "They're my noises--get off the line," and resumed the radio signals.

For their part, the Sri Lankan authorities seemed to be aware of the gaps in their censorship curtain, and also seemed not to care as long as "gross violations" were not incurred.

Indeed, after Liyanage had refused to approve any part of a lengthy on-the-scene report on the Tamil city of Jaffna that I submitted, I complained about it to President Junius R. Jayewardene at the end of an interview in his home.

Jayewardene smiled and replied, "There are ways around censorship. Go to Madras and send it."