In the age of sail, a gunboat was usually a small undecked vessel carrying a single smoothbore cannon in the bow. A gunboat could carry one or two masts or be oar-powered only, but the single-masted version of about 50 ft length was most typical. Some types of gunboats carried two cannons, or else mounted a number of swivel guns on the railings.
The advantages of this type of gunboat were that since it only carried a single cannon, that cannon could be quite heavy - for instance a 32-pounder, and that the boat could be maneuvered in shallow or restricted waters, where the sailing was quite difficult for larger ships. A single broadside from a frigate would demolish a gunboat, but a frigate facing a half-dozen gunboats in an estuary would likely be seriously damaged before it could manage to sink all of them. Gunboats were also easy and quick to build; the combatants in the 1776 Battle of Valcour Island on New York's Lake Champlain were mostly gunboats built on the spot.
All navies of the sailing era kept a number of gunboats on hand. Gunboats were a key part of the French plans to invade Great Britain in 1804, and were heavily used by Denmark. Between 1803 and 1812, the US Navy had a policy of basing the naval forces on coastal gunboats, and experimented with a variety of designs, but they were nearly useless in the War of 1812, and went back to being special-purpose vessels.
The term experienced a revival in the American Civil War, and was commonly used for armed sidewheel steamers, which frequently mounted a dozen guns or more, sometimes of rather large caliber.
In the later 19th century and early 20th century, "gunboat" was the common name for smaller armed vessels, often called "patrol gunboats". In the US Navy, these boats had the hull classification symbol "PG"; they usually displaced under 2,000 tons, were about 200 ft long, drafted 10-15 feet and sometimes much less, and mounted several guns of caliber up to 5-6 inches. An important characteristic of these was the ability to operate in rivers, enabling them to reach inland targets in a way not otherwise possible before the development of aircraft. In this period, gunboats were used by the naval powers for police actions in colonies or weaker countries, for example in China. It is this category of gunboat that inspired the term "gunboat diplomacy".
Post-World War II, the terms "motor gunboat" came to be used for smaller vessels, with displacements in the 500-ton range. US river gunboats in the Vietnam War became known as the "Brownwater Navy".