Connect to server and send query