It depends on how you will use the host name.
If you convert it directly with gethostbyname (which is the
safest solution), you can probably accept any hostname.
If you pass it to some external program or shell,
you'll have to check what characters that program accepts.
The important point here is not to check that the
hostname is a valid hostname, but rather that it
using it won't do something bad. That is, even if a hostname
is valid, it can screw your program if whatever you pass it
misinterprets it. If the hostname for example starts with a
hyphen (I don't know if that can be valid or not), and
you call a program with it and it interprets it as a
switch, that's bad, even though the user
gave you a valid hostname.