new file host.c, refactored from mget.c