You need to understand about DNS resolution. All machines first try to resolve names from their own hosts file. So you can put hostname to ip mappings there for testing. On Vista you need to run notepad as Administrator then open the file at
c:\Windows\system32\Drivers\etc\hosts
its a text file with no extension.
You will see that it already has a record for localhost. Thats how it knows to respond on localhost.
You can add arbitrary host names like
testhost 127.0.0.1
hamsandwich.com 127.0.0.1
and then you can use these host names for testing.
Hope it helps,
Joe