open_socket function

Open a socket on ip and port.