使用curl時,有兩個超時時間:一個是連接超時時間,另一個是數據傳輸的最大允許時間。
連接超時時間用 --connect-timeout 參數來指定,數據傳輸的最大允許時間用 -m 參數來指定。
例如:
curl --connect-timeout 10 -m 20 "http://XXXXXXX"
連接超時的話,出錯提示形如:
curl: (28) connect() timed out!
數據傳輸的最大允許時間超時的話,出錯提示形如:
curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received