使用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
參考: