Code

connect.c: move duplicated code to a new function 'get_host_and_port'