quit returns -1 if connection is available