Return 0 when connection failed