The Bangalore fort was captured by the British armies under Lord Cornwallis on 21 March 1791 during the Third Anglo-Mysore War and formed a centre for British resistance against Tipu Sultan. Following Tipu's death in the Fourth Anglo-Mysore War (1799), the British returned administrative control of the Bangalore "pētē" to the Maharaja of Mysore and was incorporated into the Princely State of Mysore, which existed as a nominally sovereign entity of the British Raj. The old city ("pētē") developed in the dominions of the Maharaja of Mysore. The Residency of Mysore State was first established in Mysore City in 1799 and later shifted to Bangalore in 1804. It was abolished in 1843 only to be revived in 1881 at Bangalore and to be closed down permanently in 1947, with Indian independence. The British found Bangalore to be a pleasant and appropriate place to station their garrison and therefore moved their cantonment to Bangalore from Seringapatam in 1809 near Ulsoor, about northeast of the city. A town grew up around the cantonment, by absorbing several villages in the area. The new centre had its own municipal and administrative apparatus, though technically it was a British enclave within the territory of the Wodeyar Kings of the Princely State of Mysore. Two important developments which contributed to the rapid growth of the city, include the introduction of telegraph connections to all major Indian cities in 1853 and a rail connection to Madras, in 1864.