I'm re-reading Yoshikawa Eiji's Taiko for the nth time and one thing that stood out to me was that in all the sieges mentioned in the novel, nothing was said of what happened to the castle towns which usually sprung up nearby. Did the townspeople flee into the castle like they did in Europe, or did they all go somewhere else?
YES! YES!! I bought Kindle books just to answer this thread yesterday, can't believe I can use them again so soon! Woot!
Cough
So I am not familiar with European castletowns, so I can't say how it compares, but here goes:
The 城下町 (Jōkamachi - Castle Town) likely did not just organically spring up out of existence but was built with defense in mind. The winding and narrow streets are part of the maze of the castle's design, and could be (and on occasionally were) employed to great effects in repelling the assault.
A lot, probably most castles would actually not have a castle town. Most castles are small military forts. Only large daimyo castles, usually hirajiro (plains castle) would have castle towns.
So the first order of business for the assaulting army when investing a castle is to burn the castle town down. This seem to have been standard business in clearing the area for long term operations. As far as my sources go soldiers and retainers would pull back into the castle and prepare for defense. Civilians on the other hand would evacuate the area entirely and go into hiding somewhere away from it all. Nishimata is of the opinion that castles aren't designed to hold the civilian population, and the surviving sources show no sign of any care on part of the castle to protect the castle town or its people.
In the really late Sengoku, however, some daimyos have decided that the castle town is actually important enough that it should be protected in a siege. So they built wall and moat systems to encompass the castle town as well. This only applies to the largest of daimyos and castles like Osaka and Odawara, and was very rare.
Sources:
城取りの軍事学 (Military Studies of Taking a Castle) – 西股総生 (Nishimata Fusao) 2013
戦国の城 (Castles of the Sengoku) – 小和田哲男 (Owada Tetsuo) 2011
Having wrote all that, I know of exceptions. Like everything else in history there's probably no hard-and-fast rules.
When Toyotomi Hideyoshi invested Miki and Tottori (the former's mentioned in yesterday's thread) the civilians were put under the siege as well, probably on purpose to eat up the castle's supply of food. Owada seem to be more implicitly accepting of the castle receiving and protecting people not of the garrison/retainer population (Note: Owada is more of the traditionalist/conjecture camp and Nishimata is more of the revisionist/work-from-sources-only camp so when they're in disagreement I'd go with Nishimata personally). I am not sure what happened to the castle town in these instances, but at least at Miki the siege was done by a ring of fortresses instead of a close-up encircling army, perhaps the castle town was left alone.
The other exception is the first battle of Ueda. Sanada Masayuki, being heavily outnumbered, seem to have gathered a considerable amount of the civilian population for the defense of Ueda castle. Also need to keep in mind here as well as above that the line between soldier and civilian at this point in time is not clear, as most soldiers were feudal levies.
The Tokugawa forces engaged the Sanada forces outside the castle complex, and the Sanada forces retreated into the castle. The Tokugawa forces apparently wanted to try to take the castle with a quick assault on that day, and rushed after the Sanada forces without burning down the castle town (it was suggested, but declined to prevent burning Tokugawa's own forces). At the main bailey the Sanada turned around and counterattacked the Tokugawa forces, disoriented by the maize of the castle town and ambush set within it. The Tokugawa forces began retreating, when the Sanada forces set fire to their own castle town to hinder the Tokugawa retreat.
So in this case it seems even though Sanada employed (at least some of) the non-garrison/retainer population, they really didn't care about the castle town itself beyond its military uses. And it really might have been better for the besieger to torch the place.