tcp: Add helper functions to lookup hostnames and create sockets.