Not directly answering your questions, but maybe you are looking
for something like port knocking (google
for other references, there are plenty...). The idea is to generally
keep all ports closed, and only open specific ones (HTTP, SSH,
whatever...) temporarily, if a magic pattern of requests is made to
selected closed ports (typically only known to the initiated clients).
This isn't supported by any browsers (AFAIK), but there is some
prototype code
in Perl, in case you want to play with it... Have fun!