Returns -1 when connection failed