For every call of getservbyname/getservbyport the lookup of /etc/services is done by opening the file and parsing each line one-by-one. This is slow, but the implementation is simple. This change also adds fixes for the gethostbyname function.